feat: rebuild theme on web settings changed

This commit is contained in:
2025-01-23 09:04:50 +01:00
parent 1e3c2f6a51
commit d5a4345600
13 changed files with 167 additions and 10 deletions
@@ -0,0 +1,30 @@
import os
from django.conf import settings
from django.core.management.base import BaseCommand
from django.template.loader import render_to_string
from django.core.management import call_command
from web.models import WebSettings
class Command(BaseCommand):
"""
Usage:
python manage.py build_tailwind_theme
"""
def handle(self, *args, **options):
web_settings = WebSettings.load()
path = os.path.join(
settings.BASE_DIR, "theme", "static_src", "tailwind.config.js"
)
result = str(
render_to_string(
"theme/tailwind.config.template.js", context=web_settings.theme_colors
)
)
with open(path, "w") as f:
f.write(result)
call_command("tailwind", "build")
call_command("collectstatic", "--no-input")