Files
Andros Fenollosa 19f4e84a30 Remove user FK from all models, add goals and promises
- Remove user ForeignKey from all 7 models (single-user app)
- Update all views, handlers, forms, admin, API, seed, and tests
- Add MonthlyGoal model with goals and promises sections
- Goals/promises: add, toggle (strikethrough), delete via LiveView
2026-03-18 15:18:50 +01:00

30 lines
571 B
Python

from liveview import liveview_handler, send
from app.monthly.models import MonthlyNote
@liveview_handler("save_monthly_note")
def save_monthly_note(consumer, content):
form = content.get("form", {})
year = int(form.get("year", 0))
month = int(form.get("month", 0))
text = form.get("notes", "")
if not year or not month:
return
note, _ = MonthlyNote.objects.get_or_create(
year=year,
month=month,
)
note.text = text
note.save()
send(
consumer,
{
"target": "#notes-status",
"html": '<span class="text-success text-sm">Saved</span>',
},
)