feat(profiles): notes shown on postcards page, save stays on current page
This commit is contained in:
@@ -452,12 +452,12 @@ def profile_rename(profile_id: int, nickname: str = Form(...), user: User = Depe
|
|||||||
|
|
||||||
|
|
||||||
@router.post("/profiles/{profile_id}/notes")
|
@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)):
|
def profile_notes(profile_id: int, notes: str = Form(""), redirect_to: str = Form("/profiles"), 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()
|
p = db.query(Profile).filter(Profile.id == profile_id, Profile.user_id == user.id).first()
|
||||||
if p:
|
if p:
|
||||||
p.notes = notes
|
p.notes = notes
|
||||||
db.commit()
|
db.commit()
|
||||||
return _redirect("/profiles")
|
return _redirect(redirect_to)
|
||||||
|
|
||||||
|
|
||||||
# ---------- Postcards ----------
|
# ---------- Postcards ----------
|
||||||
|
|||||||
@@ -5,6 +5,13 @@
|
|||||||
<h1>{{ profile.nickname }} 的明信片</h1>
|
<h1>{{ profile.nickname }} 的明信片</h1>
|
||||||
<a href="/profiles/{{ profile.id }}/postcards/new" class="btn btn-primary">+ 新明信片</a>
|
<a href="/profiles/{{ profile.id }}/postcards/new" class="btn btn-primary">+ 新明信片</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div style="margin-bottom:1rem">
|
||||||
|
<form method="post" action="/profiles/{{ profile.id }}/notes" style="display:flex;align-items:flex-start;gap:.4rem">
|
||||||
|
<input type="hidden" name="redirect_to" value="/profiles/{{ profile.id }}/postcards">
|
||||||
|
<textarea name="notes" rows="1" placeholder="备注(仅自己可见)" style="flex:1;padding:.3rem .5rem;border:1px solid var(--border);border-radius:6px;font-size:.8rem;resize:none;font-family:inherit;line-height:1.4;min-height:1.6rem">{{ profile.notes }}</textarea>
|
||||||
|
<button type="submit" class="btn btn-sm" style="flex-shrink:0;margin-top:0">保存</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
<div class="filter-bar">
|
<div class="filter-bar">
|
||||||
<form method="get" class="form-row">
|
<form method="get" class="form-row">
|
||||||
<select name="country">
|
<select name="country">
|
||||||
|
|||||||
@@ -48,12 +48,10 @@
|
|||||||
<span class="stat-label">国家</span>
|
<span class="stat-label">国家</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="profile-card-notes" style="padding:0 .75rem">
|
<div class="profile-card-notes" style="padding:.5rem .75rem;border-top:1px solid var(--border)">
|
||||||
<form method="post" action="/profiles/{{ p.id }}/notes" style="display:flex;flex-direction:column;gap:.3rem">
|
<form method="post" action="/profiles/{{ p.id }}/notes" style="display:flex;align-items:flex-start;gap:.4rem">
|
||||||
<textarea name="notes" rows="2" placeholder="备注(仅自己可见)" style="width:100%;padding:.4rem .6rem;border:1px solid var(--border);border-radius:6px;font-size:.85rem;resize:vertical;font-family:inherit">{{ p.notes }}</textarea>
|
<textarea name="notes" rows="1" placeholder="备注(仅自己可见)" style="flex:1;padding:.3rem .5rem;border:1px solid var(--border);border-radius:6px;font-size:.8rem;resize:none;font-family:inherit;line-height:1.4;min-height:1.6rem">{{ p.notes }}</textarea>
|
||||||
<div style="display:flex;justify-content:flex-end">
|
<button type="submit" class="btn btn-sm" style="flex-shrink:0;margin-top:0">保存</button>
|
||||||
<button type="submit" class="btn btn-sm">保存</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="profile-card-footer">
|
<div class="profile-card-footer">
|
||||||
|
|||||||
Reference in New Issue
Block a user