journal: multi-select emotions and per-category writing templates

- Mood switches from a single enum column to a many-to-many
  JournalEntryMood table so an entry can carry several feelings at
  once; the vocabulary is trimmed to 9 named emotions (dropped the
  overlapping satisfaction scale) with unified noun-style labels.
- Categories can define a content_template that pre-fills the "new
  entry" textarea when selected (only if the user hasn't started
  typing), seeded with a Story/Feelings/Decisions/Insights/Actions
  reflection template on the default "일상" category.
- Fixes a real attribute-injection bug found while building the
  template feature: Jinja's built-in |tojson filter doesn't escape
  double quotes, which breaks a double-quoted x-data="..." attribute
  when the JSON payload contains one; added |forceescape and a
  regression test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-04 19:12:59 +09:00
co-authored by Claude Sonnet 5
parent 54c971875c
commit c466cc6639
8 changed files with 172 additions and 9 deletions
+10
View File
@@ -8,6 +8,7 @@ from app.models.journal import JournalAttachmentType, JournalMood
class JournalCategoryBase(BaseModel):
name: str
color: str | None = None
content_template: str | None = None
@field_validator("name")
@classmethod
@@ -25,6 +26,14 @@ class JournalCategoryBase(BaseModel):
v = v.strip()
return v or None
@field_validator("content_template")
@classmethod
def blank_template_to_none(cls, v: str | None) -> str | None:
if v is None:
return None
v = v.strip()
return v or None
class JournalCategoryCreate(JournalCategoryBase):
pass
@@ -36,6 +45,7 @@ class JournalCategoryOut(BaseModel):
id: int
name: str
color: str | None
content_template: str | None
sort_order: int | None
created_at: datetime