Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #5 from hsk81/master

Fixes from nephila/django-cms-themes
  • Loading branch information...
commit 30ea272d6b766a06f24e690b3ec9854996279777 2 parents fa2c36c + 95af1be
@MegaMark16 authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.