Permalink
Browse files

Auto add themes dir to STATICFILES_DIRS

  • Loading branch information...
1 parent 1f8e4de commit 014f19a8f2e06e61190b086c7ca683b5e25dc3bf @yakky yakky committed Feb 18, 2012
Showing with 8 additions and 4 deletions.
  1. +8 −4 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,8 +48,9 @@ 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

0 comments on commit 014f19a

Please sign in to comment.