Skip to content
Snippets Groups Projects
Verified Commit 2229692f authored by Nik | Klampfradler's avatar Nik | Klampfradler Committed by Jonathan Weth
Browse files

Rename lazy_config to lazy_preference and add section as argument

parent d139058c
No related branches found
No related tags found
1 merge request!217Migrate from constance to dynamic-preferences
......@@ -9,7 +9,7 @@ from django.utils.translation import gettext_lazy as _
from dynaconf import LazySettings
from easy_thumbnails.conf import Settings as thumbnail_settings
from .util.core_helpers import get_app_packages, lazy_config, merge_app_settings
from .util.core_helpers import get_app_packages, lazy_preference, merge_app_settings
ENVVAR_PREFIX_FOR_DYNACONF = "ALEKSIS"
DIRS_FOR_DYNACONF = ["/etc/aleksis"]
......@@ -410,9 +410,9 @@ if _settings.get("celery.enabled", False):
INSTALLED_APPS += ("djcelery_email",)
EMAIL_BACKEND = "djcelery_email.backends.CeleryEmailBackend"
PWA_APP_NAME = lazy_config("SITE_TITLE")
PWA_APP_DESCRIPTION = lazy_config("SITE_DESCRIPTION")
PWA_APP_THEME_COLOR = lazy_config("COLOUR_PRIMARY")
PWA_APP_NAME = lazy_config("general", "title")
PWA_APP_DESCRIPTION = lazy_config("general", "description")
PWA_APP_THEME_COLOR = lazy_config("theme", "primary")
PWA_APP_BACKGROUND_COLOR = "#ffffff"
PWA_APP_DISPLAY = "standalone"
PWA_APP_ORIENTATION = "any"
......
......@@ -88,14 +88,14 @@ def merge_app_settings(setting: str, original: Union[dict, list], deduplicate: b
raise TypeError("Only dict and list settings can be merged.")
def lazy_config(key: str) -> Callable[[str], Any]:
def lazy_preference(section: str, name: str) -> Callable[[str, str], Any]:
""" Lazily get a config value from dynamic preferences. Useful to bind preferences
to other global settings to make them available to third-party apps that are not
aware of dynamic preferences.
"""
def _get_config(key: str) -> Any:
return global_preferences[key]
def _get_preference(section: str, name: str) -> Any:
return global_preferences["%s__%s" % (section, name)]
# The type is guessed from the default value to improve lazy()'s behaviour
# FIXME Reintroduce the behaviour described above
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment