mirror of
https://github.com/narrrl/holy-flavor-rater.git
synced 2026-11-03 16:41:27 +01:00
made settings page for banner dynamic from the settings json
This commit is contained in:
1 parent
dd67fa4b79
commit
94b98d7077
8 files changed
+232
-48
No files matched your search
@@ -37,18 +37,26 @@ class Command(BaseCommand):
|
||||
|
||||
if not created:
|
||||
# Sync missing settings from JSON to DB without overwriting existing keys
|
||||
db_settings = banner.settings or {}
|
||||
json_settings = data.get('settings', {})
|
||||
db_settings = banner.settings or {}
|
||||
json_settings = data.get('settings', {})
|
||||
json_schema = data.get('schema', [])
|
||||
|
||||
updated = False
|
||||
# Sync missing settings
|
||||
for key, value in json_settings.items():
|
||||
if key not in db_settings:
|
||||
db_settings[key] = value
|
||||
updated = True
|
||||
|
||||
# Always sync schema as it represents the UI structure
|
||||
if banner.schema != json_schema:
|
||||
banner.schema = json_schema
|
||||
updated = True
|
||||
|
||||
if updated:
|
||||
banner.settings = db_settings
|
||||
banner.save()
|
||||
|
||||
updated = False
|
||||
for key, value in json_settings.items():
|
||||
if key not in db_settings:
|
||||
db_settings[key] = value
|
||||
updated = True
|
||||
|
||||
if updated:
|
||||
banner.settings = db_settings
|
||||
banner.save()
|
||||
self.stdout.write(self.style.SUCCESS(f"Synced new settings for banner '{slug}' from {filename}"))
|
||||
else:
|
||||
self.stdout.write(self.style.SUCCESS(f"Created new banner '{slug}' from {filename}"))
|
||||
|
||||
Reference in new issue
Block a user