fix(postcard): mark-sent also uses fetch+reload, stays on current page
This commit is contained in:
+3
-3
@@ -919,7 +919,7 @@ async def mark_delivered(
|
|||||||
|
|
||||||
|
|
||||||
@router.post("/postcards/{postcard_id}/mark-sent")
|
@router.post("/postcards/{postcard_id}/mark-sent")
|
||||||
def mark_sent(
|
async def mark_sent(
|
||||||
postcard_id: int,
|
postcard_id: int,
|
||||||
user: User = Depends(get_current_user_web),
|
user: User = Depends(get_current_user_web),
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
@@ -932,12 +932,12 @@ def mark_sent(
|
|||||||
.first()
|
.first()
|
||||||
)
|
)
|
||||||
if not pc:
|
if not pc:
|
||||||
return _redirect("/profiles")
|
return JSONResponse({"ok": False}, status_code=404)
|
||||||
pc.status = "sent"
|
pc.status = "sent"
|
||||||
if not pc.send_time:
|
if not pc.send_time:
|
||||||
pc.send_time = datetime.now()
|
pc.send_time = datetime.now()
|
||||||
db.commit()
|
db.commit()
|
||||||
return _redirect(f"/postcards/{postcard_id}")
|
return JSONResponse({"ok": True})
|
||||||
|
|
||||||
|
|
||||||
# ---------- Image Upload ----------
|
# ---------- Image Upload ----------
|
||||||
|
|||||||
@@ -10,9 +10,7 @@
|
|||||||
<div class="detail-actions">
|
<div class="detail-actions">
|
||||||
<a href="/postcards/{{ postcard.id }}/edit" class="btn">{{ 'pc_detail.edit'|t(user.language) }}</a>
|
<a href="/postcards/{{ postcard.id }}/edit" class="btn">{{ 'pc_detail.edit'|t(user.language) }}</a>
|
||||||
{% if postcard.status == 'pending' %}
|
{% if postcard.status == 'pending' %}
|
||||||
<form method="post" action="/postcards/{{ postcard.id }}/mark-sent" class="inline">
|
<button type="button" class="btn btn-primary" onclick="if(confirm('{{ 'pc_detail.confirm_sent'|t(user.language) }}'))fetch('/postcards/{{ postcard.id }}/mark-sent',{method:'POST'}).then(function(){location.reload();})">{{ 'pc_detail.mark_sent'|t(user.language) }}</button>
|
||||||
<button type="submit" class="btn btn-primary" onclick="return confirm('{{ 'pc_detail.confirm_sent'|t(user.language) }}')">{{ 'pc_detail.mark_sent'|t(user.language) }}</button>
|
|
||||||
</form>
|
|
||||||
{% elif postcard.status == 'sent' %}
|
{% elif postcard.status == 'sent' %}
|
||||||
<button type="button" class="btn btn-primary" onclick="if(confirm('{{ 'pc_detail.confirm_delivered'|t(user.language) }}'))fetch('/postcards/{{ postcard.id }}/mark-delivered',{method:'POST'}).then(function(){location.reload();})">{{ 'pc_detail.mark_delivered'|t(user.language) }}</button>
|
<button type="button" class="btn btn-primary" onclick="if(confirm('{{ 'pc_detail.confirm_delivered'|t(user.language) }}'))fetch('/postcards/{{ postcard.id }}/mark-delivered',{method:'POST'}).then(function(){location.reload();})">{{ 'pc_detail.mark_delivered'|t(user.language) }}</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -56,9 +56,7 @@
|
|||||||
{% if pc.notes %}<span class="postcard-row-notes">{{ pc.notes[:50] }}{% if pc.notes|length > 50 %}…{% endif %}</span>{% endif %}
|
{% if pc.notes %}<span class="postcard-row-notes">{{ pc.notes[:50] }}{% if pc.notes|length > 50 %}…{% endif %}</span>{% endif %}
|
||||||
<div class="postcard-row-action">
|
<div class="postcard-row-action">
|
||||||
{% if pc.status == 'pending' %}
|
{% if pc.status == 'pending' %}
|
||||||
<form method="post" action="/postcards/{{ pc.id }}/mark-sent" onclick="event.preventDefault();event.stopPropagation();if(confirm('{{ 'pc_list.confirm_sent'|t(user.language) }}'))this.submit();">
|
<button type="button" class="btn btn-sm btn-primary" onclick="event.preventDefault();event.stopPropagation();if(confirm('{{ 'pc_list.confirm_sent'|t(user.language) }}'))fetch('/postcards/{{ pc.id }}/mark-sent',{method:'POST'}).then(function(){location.reload();})">{{ 'pc_list.mark_sent'|t(user.language) }}</button>
|
||||||
<button type="submit" class="btn btn-sm btn-primary">{{ 'pc_list.mark_sent'|t(user.language) }}</button>
|
|
||||||
</form>
|
|
||||||
{% elif pc.status == 'sent' %}
|
{% elif pc.status == 'sent' %}
|
||||||
<button type="button" class="btn btn-sm btn-primary" onclick="event.preventDefault();event.stopPropagation();if(confirm('{{ 'pc_list.confirm_delivered'|t(user.language) }}'))fetch('/postcards/{{ pc.id }}/mark-delivered',{method:'POST'}).then(function(){location.reload();})">{{ 'pc_list.mark_delivered'|t(user.language) }}</button>
|
<button type="button" class="btn btn-sm btn-primary" onclick="event.preventDefault();event.stopPropagation();if(confirm('{{ 'pc_list.confirm_delivered'|t(user.language) }}'))fetch('/postcards/{{ pc.id }}/mark-delivered',{method:'POST'}).then(function(){location.reload();})">{{ 'pc_list.mark_delivered'|t(user.language) }}</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
Reference in New Issue
Block a user