confirm screen before merge/delete
This commit is contained in:
parent
4fbf0712ca
commit
65d1dfe536
5 changed files with 179 additions and 11 deletions
|
@ -184,11 +184,10 @@
|
|||
<details>
|
||||
<summary>{% trans '合并' %}</summary>
|
||||
<form method="post"
|
||||
action="{% url 'catalog:merge' item.url_path item.uuid %}"
|
||||
onsubmit="return confirm('本操作不可撤销。确认合并吗?');">
|
||||
action="{% url 'catalog:merge' item.url_path item.uuid %}">
|
||||
{% csrf_token %}
|
||||
<input type="url"
|
||||
name="new_item_url"
|
||||
name="target_item_url"
|
||||
placeholder="目标条目URL,留空则取消现有合并"
|
||||
{% if item.is_deleted and not item.merged_to_item %}disabled{% endif %}
|
||||
value="{{ item.merged_to_item.absolute_url }}">
|
||||
|
@ -204,8 +203,7 @@
|
|||
<details>
|
||||
<summary>{% trans '删除' %}</summary>
|
||||
<form method="post"
|
||||
action="{% url 'catalog:delete' item.url_path item.uuid %}"
|
||||
onsubmit="return confirm('本操作不可撤销。确认删除吗?');">
|
||||
action="{% url 'catalog:delete' item.url_path item.uuid %}">
|
||||
{% csrf_token %}
|
||||
<input class="contrast"
|
||||
type="submit"
|
||||
|
|
56
catalog/templates/catalog_delete.html
Normal file
56
catalog/templates/catalog_delete.html
Normal file
|
@ -0,0 +1,56 @@
|
|||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% load l10n %}
|
||||
{% load admin_url %}
|
||||
{% load mastodon %}
|
||||
{% load oauth_token %}
|
||||
{% load truncate %}
|
||||
{% load thumb %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ site_name }} - {% trans 'Confirmation' %}</title>
|
||||
{% include "common_libs.html" %}
|
||||
{% if url %}<meta http-equiv="refresh" content="3;url={{ url }}">{% endif %}
|
||||
</head>
|
||||
<body>
|
||||
{% include "_header.html" %}
|
||||
<main class="container">
|
||||
<h2>{% trans 'Are you sure to delete?' %}</h2>
|
||||
<div>
|
||||
<article class="item-card deleting">{% include "_item_card.html" with item=item %}</article>
|
||||
{% if item.is_deleted %}
|
||||
<p>
|
||||
<i class="fa-solid fa-circle-xmark"></i> 条目已被删除
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if item.child_items %}
|
||||
<p>
|
||||
<i class="fa-solid fa-circle-exclamation"></i> 条目下已有子项
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if item.merged_to_item %}
|
||||
<p>
|
||||
<i class="fa-solid fa-circle-xmark"></i> 条目已被合并到其他条目
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if item.journal_exists %}
|
||||
<p>
|
||||
<i class="fa-solid fa-circle-exclamation"></i> 条目已被用户标记过
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<form method="post"
|
||||
action="{% url 'catalog:delete' item.url_path item.uuid %}"
|
||||
onsubmit="return confirm('本操作不可撤销。确认吗?');">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="sure" value="1">
|
||||
<input type="submit" value="{% trans 'Yes' %}">
|
||||
<input type="reset" value="{% trans 'No' %}" onclick="history.go(-1)">
|
||||
</form>
|
||||
</main>
|
||||
{% include "_footer.html" %}
|
||||
</body>
|
||||
</html>
|
94
catalog/templates/catalog_merge.html
Normal file
94
catalog/templates/catalog_merge.html
Normal file
|
@ -0,0 +1,94 @@
|
|||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% load l10n %}
|
||||
{% load admin_url %}
|
||||
{% load mastodon %}
|
||||
{% load oauth_token %}
|
||||
{% load truncate %}
|
||||
{% load thumb %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ site_name }} - {% trans 'Confirmation' %}</title>
|
||||
{% include "common_libs.html" %}
|
||||
{% if url %}<meta http-equiv="refresh" content="3;url={{ url }}">{% endif %}
|
||||
</head>
|
||||
<body>
|
||||
{% include "_header.html" %}
|
||||
<main class="container">
|
||||
<h2>
|
||||
{% if new_item %}
|
||||
{% trans 'Are you sure to merge?' %}
|
||||
{% else %}
|
||||
{% trans 'Are you sure to cancel merge?' %}
|
||||
{% endif %}
|
||||
</h2>
|
||||
<div>
|
||||
<article class="item-card deleting">{% include "_item_card.html" with item=item %}</article>
|
||||
{% if item.is_deleted %}
|
||||
<p>
|
||||
<i class="fa-solid fa-circle-xmark"></i> 条目已被删除
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if item.child_items %}
|
||||
<p>
|
||||
<i class="fa-solid fa-circle-exclamation"></i> 条目下已有子项
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if item.merged_to_item %}
|
||||
<p>
|
||||
<i class="fa-solid fa-circle-xmark"></i> 条目已被合并到其他条目
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if item.journal_exists %}
|
||||
<p>
|
||||
<i class="fa-solid fa-circle-exclamation"></i> 条目已被用户标记过
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if new_item %}
|
||||
<div>
|
||||
<center><i class="fa-solid fa-angles-down"></i>
|
||||
<i class="fa-solid fa-angles-down"></i>
|
||||
<i class="fa-solid fa-angles-down"></i>
|
||||
</center>
|
||||
</div>
|
||||
<article class="item-card">{% include "_item_card.html" with item=new_item %}</article>
|
||||
{% if new_item.is_deleted %}
|
||||
<p>
|
||||
<i class="fa-solid fa-circle-xmark"></i> 条目已被删除
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if new_item.child_items %}
|
||||
<p>
|
||||
<i class="fa-solid fa-circle-exclamation"></i> 条目下已有子项
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if new_item.merged_to_item %}
|
||||
<p>
|
||||
<i class="fa-solid fa-circle-xmark"></i> 条目已被合并到其他条目
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if new_item.journal_exists %}
|
||||
<p>
|
||||
<i class="fa-solid fa-circle-exclamation"></i> 条目已被用户标记过
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<form method="post"
|
||||
action="{% url 'catalog:merge' item.url_path item.uuid %}"
|
||||
onsubmit="return confirm('本操作不可撤销。确认吗?');">
|
||||
{% csrf_token %}
|
||||
<input type="hidden"
|
||||
name="target_item_url"
|
||||
value="{{ request.POST.target_item_url }}">
|
||||
<input type="hidden" name="sure" value="1">
|
||||
<input type="submit" value="{% trans 'Yes' %}">
|
||||
<input type="reset" value="{% trans 'No' %}" onclick="history.go(-1)">
|
||||
</form>
|
||||
</main>
|
||||
{% include "_footer.html" %}
|
||||
</body>
|
||||
</html>
|
|
@ -126,10 +126,15 @@ def delete(request, item_path, item_uuid):
|
|||
item = get_object_or_404(Item, uid=get_uuid_or_404(item_uuid))
|
||||
if not request.user.is_staff and item.journal_exists():
|
||||
raise PermissionDenied()
|
||||
item.delete()
|
||||
return (
|
||||
redirect(item.url + "?skipcheck=1") if request.user.is_staff else redirect("/")
|
||||
)
|
||||
if request.POST.get("sure", 0) != "1":
|
||||
return render(request, "catalog_delete.html", {"item": item})
|
||||
else:
|
||||
item.delete()
|
||||
return (
|
||||
redirect(item.url + "?skipcheck=1")
|
||||
if request.user.is_staff
|
||||
else redirect("/")
|
||||
)
|
||||
|
||||
|
||||
@require_http_methods(["POST"])
|
||||
|
@ -254,8 +259,13 @@ def merge(request, item_path, item_uuid):
|
|||
item = get_object_or_404(Item, uid=get_uuid_or_404(item_uuid))
|
||||
if not request.user.is_staff and item.journal_exists():
|
||||
raise PermissionDenied()
|
||||
if request.POST.get("new_item_url"):
|
||||
new_item = Item.get_by_url(request.POST.get("new_item_url"))
|
||||
if request.POST.get("sure", 0) != "1":
|
||||
new_item = Item.get_by_url(request.POST.get("target_item_url"))
|
||||
return render(
|
||||
request, "catalog_merge.html", {"item": item, "new_item": new_item}
|
||||
)
|
||||
elif request.POST.get("target_item_url"):
|
||||
new_item = Item.get_by_url(request.POST.get("target_item_url"))
|
||||
if not new_item or new_item.is_deleted or new_item.merged_to_item_id:
|
||||
raise BadRequest(_("Cannot be merged to an item already deleted or merged"))
|
||||
if new_item.class_name != item.class_name:
|
||||
|
|
|
@ -84,6 +84,16 @@ details {
|
|||
color: var(--pico-muted-color);
|
||||
}
|
||||
|
||||
.deleting {
|
||||
background: repeating-linear-gradient(
|
||||
135deg,
|
||||
var(--pico-muted-border-color),
|
||||
var(--pico-muted-border-color) 10px,
|
||||
var(--pico-background-color) 10px,
|
||||
var(--pico-background-color) 20px
|
||||
);
|
||||
}
|
||||
|
||||
.hint {
|
||||
color: var(--pico-muted-color);
|
||||
opacity: 0.5;
|
||||
|
|
Loading…
Add table
Reference in a new issue