diff --git a/src/wagtailthemes/models.py b/src/wagtailthemes/models.py index f582870..eb87761 100644 --- a/src/wagtailthemes/models.py +++ b/src/wagtailthemes/models.py @@ -1,13 +1,19 @@ +from django import forms from django.conf import settings from django.db import models from wagtail.contrib.settings.models import BaseSetting, register_setting +from wagtail.wagtailadmin.edit_handlers import FieldPanel __ALL__ = ['ThemeSettings'] + @register_setting class ThemeSettings(BaseSetting): THEMES = getattr(settings, 'WAGTAIL_THEMES', None) - theme = models.CharField( - blank=True, choices=THEMES, max_length=255, null=True) + theme = models.CharField(blank=True, max_length=255, null=True) + + panels = [ + FieldPanel('theme', widget=forms.Select(choices=THEMES)) + ] diff --git a/src/wagtailthemes/thread.py b/src/wagtailthemes/thread.py index 1e8d913..5aabc71 100644 --- a/src/wagtailthemes/thread.py +++ b/src/wagtailthemes/thread.py @@ -7,6 +7,7 @@ def set_theme(theme): setattr(_thread_locals, 'wagtail_theme', theme) + def get_theme(): theme = getattr(_thread_locals, 'wagtail_theme', None) return theme