diff --git a/cookbook/templatetags/theming_tags.py b/cookbook/templatetags/theming_tags.py index d69ae7b0..f2984b97 100644 --- a/cookbook/templatetags/theming_tags.py +++ b/cookbook/templatetags/theming_tags.py @@ -3,7 +3,7 @@ from django.templatetags.static import static from django_scopes import scopes_disabled from cookbook.models import UserPreference, UserFile, Space -from recipes.settings import STICKY_NAV_PREF_DEFAULT, UNAUTHENTICATED_THEME_FROM_SPACE +from recipes.settings import STICKY_NAV_PREF_DEFAULT, UNAUTHENTICATED_THEME_FROM_SPACE, FORCE_THEME_FROM_SPACE register = template.Library() @@ -15,11 +15,14 @@ def theme_values(request): def get_theming_values(request): space = None - if getattr(request,'space',None): + if getattr(request, 'space', None): space = request.space - if not request.user.is_authenticated and UNAUTHENTICATED_THEME_FROM_SPACE > 0: + if not request.user.is_authenticated and UNAUTHENTICATED_THEME_FROM_SPACE > 0 and FORCE_THEME_FROM_SPACE == 0: with scopes_disabled(): space = Space.objects.filter(id=UNAUTHENTICATED_THEME_FROM_SPACE).first() + if FORCE_THEME_FROM_SPACE: + with scopes_disabled(): + space = Space.objects.filter(id=FORCE_THEME_FROM_SPACE).first() themes = { UserPreference.BOOTSTRAP: 'themes/bootstrap.min.css', diff --git a/docs/system/configuration.md b/docs/system/configuration.md index f6e64d24..8d93f985 100644 --- a/docs/system/configuration.md +++ b/docs/system/configuration.md @@ -560,6 +560,15 @@ With this setting you can specify the ID of a space of which the appearance sett UNAUTHENTICATED_THEME_FROM_SPACE= ``` +#### Force Theme +> default `0` - options `1-X` (space ID) + +Similar to the Default theme but forces the theme upon all users (authenticated/unauthenticated) and all spaces + +``` +FORCE_THEME_FROM_SPACE= +``` + ### Rate Limiting / Performance #### Shopping auto sync diff --git a/recipes/settings.py b/recipes/settings.py index 4f4328d0..36e68c4f 100644 --- a/recipes/settings.py +++ b/recipes/settings.py @@ -59,6 +59,7 @@ KJ_PREF_DEFAULT = bool(int(os.getenv('KJ_PREF_DEFAULT', False))) STICKY_NAV_PREF_DEFAULT = bool(int(os.getenv('STICKY_NAV_PREF_DEFAULT', True))) MAX_OWNED_SPACES_PREF_DEFAULT = int(os.getenv('MAX_OWNED_SPACES_PREF_DEFAULT', 100)) UNAUTHENTICATED_THEME_FROM_SPACE = int(os.getenv('UNAUTHENTICATED_THEME_FROM_SPACE', 0)) +FORCE_THEME_FROM_SPACE = int(os.getenv('FORCE_THEME_FROM_SPACE', 0)) # minimum interval that users can set for automatic sync of shopping lists SHOPPING_MIN_AUTOSYNC_INTERVAL = int(