Files
saas_backend/scripts/seed_palettes.py
T

153 lines
4.2 KiB
Python
Raw Normal View History

2026-01-17 14:18:00 +05:30
"""
Seed default color palettes
Usage: python scripts/seed_palettes.py
"""
import sys
from pathlib import Path
backend_dir = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(backend_dir))
from app.config.database import SessionLocal
2026-01-17 16:36:05 +05:30
from app.models.theme.color_palette_model import ColorPalette
2026-01-17 14:18:00 +05:30
# 1. Default Palette (Dark Navy Sidebar)
DEFAULT_PALETTE = {
"name": "Default Navy",
"description": "The default theme with navy blue sidebar",
"is_default": True,
"colors": {
"primary": "#3B82F6",
"primary_hover": "#2563EB",
"sidebar_bg": "#1D2A4B",
"sidebar_text": "#F1F5F9",
"sidebar_text_muted": "#94A3B8",
"sidebar_active_bg": "#0077FF",
"sidebar_active_text": "#FFFFFF",
"sidebar_hover_bg": "rgba(255,255,255,0.2)",
"sidebar_border": "#334155",
"header_bg": "#FFFFFF",
"header_text": "#1F2937",
"header_border": "#E5E7EB",
"background": "#F9FAFB",
"background_secondary": "#FFFFFF",
"text_primary": "#1F2937",
"text_secondary": "#6B7280",
"card_bg": "#FFFFFF",
"card_border": "#E2E8F0",
"table_header_bg": "#F8FAFC",
"table_row_hover": "#F1F5F9",
"table_border": "#E2E8F0"
}
}
# 2. Light Palette
LIGHT_PALETTE = {
"name": "Clean White",
"description": "Minimalist white theme",
"is_default": False,
"colors": {
"primary": "#2563EB",
"primary_hover": "#1D4ED8",
"sidebar_bg": "#FFFFFF",
"sidebar_text": "#374151",
"sidebar_text_muted": "#6B7280",
"sidebar_active_bg": "#EFF6FF",
"sidebar_active_text": "#2563EB",
"sidebar_hover_bg": "#F3F4F6",
"sidebar_border": "#E5E7EB",
"header_bg": "#FFFFFF",
"header_text": "#1F2937",
"header_border": "#E5E7EB",
"background": "#FFFFFF",
"background_secondary": "#F9FAFB",
"text_primary": "#111827",
"text_secondary": "#6B7280",
"card_bg": "#FFFFFF",
"card_border": "#E5E7EB",
"table_header_bg": "#F9FAFB",
"table_row_hover": "#F3F4F6",
"table_border": "#E5E7EB"
}
}
# 3. Dark Palette
DARK_PALETTE = {
"name": "Dark Mode",
"description": "Dark theme for low light environments",
"is_default": False,
"colors": {
"primary": "#60A5FA",
"primary_hover": "#3B82F6",
"sidebar_bg": "#111827",
"sidebar_text": "#E5E7EB",
"sidebar_text_muted": "#9CA3AF",
"sidebar_active_bg": "#3B82F6",
"sidebar_active_text": "#FFFFFF",
"sidebar_hover_bg": "rgba(255,255,255,0.1)",
"sidebar_border": "#374151",
"header_bg": "#1F2937",
"header_text": "#F9FAFB",
"header_border": "#374151",
"background": "#111827",
"background_secondary": "#1F2937",
"text_primary": "#F9FAFB",
"text_secondary": "#9CA3AF",
"card_bg": "#1F2937",
"card_border": "#374151",
"table_header_bg": "#111827",
"table_row_hover": "#374151",
"table_border": "#374151"
}
}
def seed_palettes():
db = SessionLocal()
try:
palettes = [DEFAULT_PALETTE, LIGHT_PALETTE, DARK_PALETTE]
for p_data in palettes:
existing = db.query(ColorPalette).filter(ColorPalette.name == p_data["name"]).first()
if not existing:
palette = ColorPalette(
name=p_data["name"],
description=p_data["description"],
is_default=p_data["is_default"],
colors=p_data["colors"],
)
db.add(palette)
2026-01-19 10:23:51 +05:30
print(f"Creating palette: {p_data['name']}")
2026-01-17 14:18:00 +05:30
else:
2026-01-19 10:23:51 +05:30
print(f"Palette already exists: {p_data['name']}")
2026-01-17 14:18:00 +05:30
existing.colors = p_data["colors"]
existing.is_default = p_data["is_default"]
db.commit()
2026-01-19 10:23:51 +05:30
print("Done seeding palettes.")
2026-01-17 14:18:00 +05:30
except Exception as e:
2026-01-19 10:23:51 +05:30
print(f"Error seeding palettes: {e}")
2026-01-17 14:18:00 +05:30
db.rollback()
finally:
db.close()
if __name__ == "__main__":
seed_palettes()