Automatically write changes to logo and font definitions to configs

This commit is contained in:
Finn Stutzenstein 2021-06-17 11:29:54 +02:00
parent 8d73f08072
commit 5d434484b5
No known key found for this signature in database
GPG Key ID: 9042F605C6324654
2 changed files with 15 additions and 0 deletions

View File

@ -157,6 +157,9 @@ def manage_config(**kwargs):
from .config import config from .config import config
altered = config.save_default_values() altered = config.save_default_values()
altered = (
config.overwrite_with_defaults("logos_available", "fonts_available") or altered
)
altered = config.cleanup_old_config_values() or altered altered = config.cleanup_old_config_values() or altered
if altered: if altered:
config.increment_version() config.increment_version()

View File

@ -250,6 +250,18 @@ class ConfigHandler:
queryset.delete() queryset.delete()
return altered_config return altered_config
def overwrite_with_defaults(self, *keys: str) -> bool:
altered_config = False
for key in keys:
config_variable = self.config_variables[key]
# it must be present in the db -> ensure that save_default_values run beforehand
db_value = ConfigStore.objects.get(key=key)
if db_value.value != config_variable.default_value:
db_value.value = config_variable.default_value
db_value.save()
altered_config = True
return altered_config
def get_collection_string(self) -> str: def get_collection_string(self) -> str:
""" """
Returns the collection_string from the CollectionStore. Returns the collection_string from the CollectionStore.