Merge pull request #6118 from FinnStutzenstein/fixFontsAndLogos

Automatically write changes to logo and font definitions to configs
This commit is contained in:
Emanuel Schütze 2021-06-17 11:51:44 +02:00 committed by GitHub
commit eeb0e54985
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

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

View File

@ -250,6 +250,18 @@ class ConfigHandler:
queryset.delete()
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:
"""
Returns the collection_string from the CollectionStore.