diff --git a/app/models.py b/app/models.py index e02777a..252946b 100644 --- a/app/models.py +++ b/app/models.py @@ -83,6 +83,8 @@ class Postcard(Base): # received sender_name = Column(String(64)) receive_time = Column(DateTime) + # misc + notes = Column(Text, nullable=False, default="") # images showcase_hidden = Column(default=False, nullable=False) image_front = Column(String(256)) diff --git a/app/routers/web.py b/app/routers/web.py index 21b3bb2..dbbe93b 100644 --- a/app/routers/web.py +++ b/app/routers/web.py @@ -529,6 +529,7 @@ def postcard_create( arrival_time: str = Form(""), sender_name: str = Form(""), receive_time: str = Form(""), + notes: str = Form(""), user: User = Depends(get_current_user_web), db: Session = Depends(get_db), ): @@ -558,6 +559,7 @@ def postcard_create( arrival_time=_parse_dt(arrival_time), sender_name=sender_name or None, receive_time=_parse_dt(receive_time), + notes=notes.strip(), ) db.add(pc) db.commit() @@ -602,6 +604,7 @@ def postcard_update( arrival_time: str = Form(""), sender_name: str = Form(""), receive_time: str = Form(""), + notes: str = Form(""), user: User = Depends(get_current_user_web), db: Session = Depends(get_db), ): @@ -634,6 +637,7 @@ def postcard_update( pc.arrival_time = None if status == "sent" else _parse_dt(arrival_time) pc.sender_name = sender_name or None pc.receive_time = _parse_dt(receive_time) + pc.notes = notes.strip() db.commit() return _redirect(f"/postcards/{postcard_id}") diff --git a/app/static/style.css b/app/static/style.css index ad44260..bf379f2 100644 --- a/app/static/style.css +++ b/app/static/style.css @@ -135,6 +135,7 @@ code { background: var(--bg); padding: .15rem .4rem; border-radius: 4px; font-si .detail-meta dl { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; } .detail-meta dt { font-weight: 600; font-size: .85rem; color: var(--text-muted); } .detail-meta dd { font-size: .95rem; } +.detail-notes { margin-top: .75rem; padding: .5rem .75rem; background: var(--bg); border-radius: 6px; font-size: .88rem; color: var(--text-muted); white-space: pre-wrap; word-break: break-word; } /* Tabs */ .tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 1rem; } @@ -215,6 +216,7 @@ code { background: var(--bg); padding: .15rem .4rem; border-radius: 4px; font-si .postcard-row-action { flex-shrink: 0; } .postcard-row-date { font-size: .78rem; color: var(--text-muted); white-space: nowrap; } .postcard-row-detail { display: flex; flex-direction: column; gap: 0; font-size: .85rem; color: var(--text-muted); } +.postcard-row-notes { font-size: .8rem; color: var(--text-muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .detail-title-row { display: flex; align-items: center; gap: .75rem; } .detail-title-row h1 { margin: 0; } .btn-back { padding: .35rem .6rem; font-size: 1rem; text-decoration: none; } diff --git a/app/templates/postcard_detail.html b/app/templates/postcard_detail.html index 522f47f..b92431a 100644 --- a/app/templates/postcard_detail.html +++ b/app/templates/postcard_detail.html @@ -61,6 +61,9 @@ {% endif %}
所属 Profile
{{ postcard.profile.nickname }}
+ {% if postcard.notes %} +
{{ postcard.notes }}
+ {% endif %} {% endblock %} diff --git a/app/templates/postcard_form.html b/app/templates/postcard_form.html index b01b9bb..37f5c4d 100644 --- a/app/templates/postcard_form.html +++ b/app/templates/postcard_form.html @@ -33,6 +33,9 @@ + + +
取消 diff --git a/app/templates/postcards.html b/app/templates/postcards.html index be35fe9..19e83e1 100644 --- a/app/templates/postcards.html +++ b/app/templates/postcards.html @@ -44,6 +44,7 @@ {{ pc.country|flag }} {{ pc.country or '-' }} → {{ pc.recipient_name or '-' }}
+ {% if pc.notes %}{{ pc.notes[:50] }}{% if pc.notes|length > 50 %}…{% endif %}{% endif %} {{ {'sent':'已寄出','delivered':'已送达'}.get(pc.status) }} {% if pc.send_time %}{{ pc.send_time.strftime('%Y-%m-%d') }}寄出{% endif %} @@ -80,6 +81,7 @@
← {{ pc.sender_name or '-' }}
+ {% if pc.notes %}{{ pc.notes[:50] }}{% if pc.notes|length > 50 %}…{% endif %}{% endif %} {% if pc.receive_time %}{{ pc.receive_time.strftime('%Y-%m-%d') }}收到{% endif %}