- Translate all templates: login, dashboard, expense success, categories CRUD, subcategory CRUD, month start page, nav bar, partials - Translate seed categories: Survival, Leisure & vice, Culture, Extras with all subcategories in English - Translate form placeholders and view titles - Translate error messages (login, delete confirmations) - Change LANGUAGE_CODE from "es" to "en-us" - Change html lang from "es" to "en" - Format all Python files with Ruff (tabs)
27 lines
773 B
Python
27 lines
773 B
Python
from liveview import liveview_handler, send
|
|
from django.template.loader import render_to_string
|
|
|
|
from app.expenses.models import Category
|
|
|
|
|
|
@liveview_handler("update_subcategories")
|
|
def update_subcategories(consumer, content):
|
|
category_id = content.get("form", {}).get("category", "")
|
|
|
|
if not category_id:
|
|
send(consumer, {"target": "#subcategory-wrapper", "html": ""})
|
|
return
|
|
|
|
try:
|
|
category = Category.objects.get(id=category_id)
|
|
subcategories = category.subcategories.all()
|
|
|
|
html = render_to_string(
|
|
"pages/expenses/partials/subcategory_select.html",
|
|
{"subcategories": subcategories},
|
|
)
|
|
send(consumer, {"target": "#subcategory-wrapper", "html": html})
|
|
|
|
except Category.DoesNotExist:
|
|
send(consumer, {"target": "#subcategory-wrapper", "html": ""})
|