made settings page for banner dynamic from the settings json

This commit is contained in:
nvrl committed 2026-02-18 14:31:57 +01:00
1 parent dd67fa4b79
commit 94b98d7077
8 files changed
+232 -48

No files matched your search

+19 -11
View File
@@ -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}"))