Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixes from nephila/django-cms-themes #5

Merged
merged 4 commits into from

3 participants

@hsk81

Hi Mark,

I took the liberty to send you nephila's fixes as a pull request. I'd trouble with issue #3 which nephila seems to have fixed, but I did not see any corresponding pull request from his side.

In addition have added one "fix" on my own which tells the OS environment to use Python 2 instead of Python 3; I don't know if some (older) setups will have trouble with

#!/usr/bin/env python2

but if so just ignore my related commit 95af1be.

@yakky

Yes, basically i didn't requested pull for the commits because i feel it's a very ugly hack, but I haven't had time to find a better solution since then.

@hsk81

So you think I should close the pull request? Still think your tweak has value .. it solved my problem.

@yakky

I'm still +1
I commited because it solves a problem, and it's one step in the right direction.
So I do hope MegaMark16 would accept this.

@MegaMark16 MegaMark16 merged commit 30ea272 into from
@MegaMark16
Owner

Thanks @hsk81 and @nephila, sorry it took so long for me to get around to merging the fix, but it works like a charm, and honestly the whole thing is kind of a hack, so it fits right in :-)

Thanks!
Mark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 22 additions and 4 deletions.
  1. +9 −4 cms_themes/__init__.py
  2. +12 −0 cms_themes/admin.py
  3. +1 −0  setup.py
View
13 cms_themes/__init__.py
@@ -1,6 +1,6 @@
VERSION = (1,0,8)
__version__ = "1.0.8"
-import random
+import random
import os
def init_themes():
@@ -18,7 +18,9 @@ def init_themes():
settings.TEMPLATE_DIRS = settings.TEMPLATE_DIRS + (settings.THEMES_DIR,)
if not hasattr(settings, 'DEFAULT_TEMPLATE_DIRS'):
setattr(settings, 'DEFAULT_TEMPLATE_DIRS', settings.TEMPLATE_DIRS)
-
+ if not hasattr(settings, 'DEFAULT_STATICFILES_DIRS'):
+ setattr(settings, 'DEFAULT_STATICFILES_DIRS', settings.STATICFILES_DIRS)
+
def set_themes():
if not Site.objects.filter(id=settings.SITE_ID):
return
@@ -32,10 +34,11 @@ def set_themes():
except:
pass
- if not themes:
+ if not themes:
return
theme_templates = []
+ theme_static = []
for theme_dir in os.listdir(settings.THEMES_DIR):
if theme_dir in themes:
theme_full_path = os.path.join(settings.THEMES_DIR, theme_dir)
@@ -45,13 +48,15 @@ def set_themes():
for template in os.listdir(template_path):
template_display = '%s (%s)' % (template.replace('_', ' ').title().split('.')[0], theme_dir)
theme_templates.append((template, template_display))
-
+
setattr(settings, 'CMS_TEMPLATES', tuple(theme_templates) + settings.DEFAULT_CMS_TEMPLATES)
+ setattr(settings, 'STATICFILES_DIRS', (settings.THEMES_DIR,) + settings.DEFAULT_STATICFILES_DIRS)
try:
from django.conf import settings
from django.contrib.sites.models import Site
from cms.conf.patch import post_patch
+ from cms_themes.models import Theme
init_themes()
set_themes()
View
12 cms_themes/admin.py
@@ -1,6 +1,8 @@
from django.contrib import admin, messages
from models import Theme
from django.conf import settings
+from django.utils.translation import ugettext, ugettext_lazy as _
+from django.db import models
class ThemeAdmin(admin.ModelAdmin):
list_display = ('id','name',)
@@ -10,3 +12,13 @@ class ThemeAdmin(admin.ModelAdmin):
readonly_fields = ('name',)
admin.site.register(Theme, ThemeAdmin)
+from cms.models import Page
+from cms.admin.pageadmin import PageAdmin
+from cms.admin.forms import PageAddForm,PageForm
+admin.site.unregister(Page)
+t = Page._meta.get_field_by_name("template")[0]
+template_choices = [(x, _(y)) for x,y in settings.CMS_TEMPLATES]
+t.choices.extend(template_choices)
+admin.site.register(Page, PageAdmin)
+
+
View
1  setup.py 100644 → 100755
@@ -1,3 +1,4 @@
+#!/usr/bin/env python2
from setuptools import setup, find_packages
import os
Something went wrong with that request. Please try again.