feat: rebuild theme on web settings changed
This commit is contained in:
@@ -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")
|
||||
Reference in New Issue
Block a user