From b6d43b3db4a7c85796b9846fd2b8c2d993b2ced8 Mon Sep 17 00:00:00 2001 From: Zichao Lin Date: Mon, 6 Jul 2026 19:36:29 +0800 Subject: [PATCH] feat(profiles): add private notes field per profile, visible only to owner --- app/models.py | 3 ++- app/routers/web.py | 9 +++++++++ app/templates/profiles.html | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/models.py b/app/models.py index 7374f42..e02777a 100644 --- a/app/models.py +++ b/app/models.py @@ -1,6 +1,6 @@ from datetime import datetime, timezone -from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String +from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String, Text from sqlalchemy.orm import relationship, validates from app.database import Base @@ -61,6 +61,7 @@ class Profile(Base): nickname = Column(String(64), nullable=False) showcase_enabled = Column(default=False, nullable=False) showcase_visible = Column(String(16), nullable=False, default="both") + notes = Column(Text, nullable=False, default="") created_at = Column(DateTime, default=_utcnow) user = relationship("User", back_populates="profiles") diff --git a/app/routers/web.py b/app/routers/web.py index 2f6b059..d9dae80 100644 --- a/app/routers/web.py +++ b/app/routers/web.py @@ -451,6 +451,15 @@ def profile_rename(profile_id: int, nickname: str = Form(...), user: User = Depe return _redirect("/profiles") +@router.post("/profiles/{profile_id}/notes") +def profile_notes(profile_id: int, notes: str = Form(""), user: User = Depends(get_current_user_web), db: Session = Depends(get_db)): + p = db.query(Profile).filter(Profile.id == profile_id, Profile.user_id == user.id).first() + if p: + p.notes = notes + db.commit() + return _redirect("/profiles") + + # ---------- Postcards ---------- @router.get("/profiles/{profile_id}/postcards", response_class=HTMLResponse) diff --git a/app/templates/profiles.html b/app/templates/profiles.html index 142e6b3..6c3f77f 100644 --- a/app/templates/profiles.html +++ b/app/templates/profiles.html @@ -48,6 +48,14 @@ 国家 +
+
+ +
+ +
+
+