31 lines
848 B
Python
31 lines
848 B
Python
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")
|