From a0661d99fa02847d34220be14c65b64138ba1007 Mon Sep 17 00:00:00 2001 From: Rob Moorman Date: Mon, 12 Sep 2016 22:15:05 +0200 Subject: [PATCH 1/2] Prevent migrating this app, use Select widget instead --- src/wagtailthemes/models.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/wagtailthemes/models.py b/src/wagtailthemes/models.py index f582870..b98b68f 100644 --- a/src/wagtailthemes/models.py +++ b/src/wagtailthemes/models.py @@ -1,6 +1,8 @@ +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'] @@ -9,5 +11,8 @@ 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)) + ] From ab2bc50ffdaea75057c2f070a8d00cc22913759a Mon Sep 17 00:00:00 2001 From: Rob Moorman Date: Mon, 12 Sep 2016 22:18:55 +0200 Subject: [PATCH 2/2] Flake8 fixes --- src/wagtailthemes/models.py | 1 + src/wagtailthemes/thread.py | 1 + 2 files changed, 2 insertions(+) diff --git a/src/wagtailthemes/models.py b/src/wagtailthemes/models.py index b98b68f..eb87761 100644 --- a/src/wagtailthemes/models.py +++ b/src/wagtailthemes/models.py @@ -7,6 +7,7 @@ __ALL__ = ['ThemeSettings'] + @register_setting class ThemeSettings(BaseSetting): THEMES = getattr(settings, 'WAGTAIL_THEMES', None) 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