diff --git a/catalog/templates/_sidebar_edit.html b/catalog/templates/_sidebar_edit.html index 1e2fe4e7..547d79ea 100644 --- a/catalog/templates/_sidebar_edit.html +++ b/catalog/templates/_sidebar_edit.html @@ -184,11 +184,10 @@
{% trans '合并' %}
+ action="{% url 'catalog:merge' item.url_path item.uuid %}"> {% csrf_token %} @@ -204,8 +203,7 @@
{% trans '删除' %} + action="{% url 'catalog:delete' item.url_path item.uuid %}"> {% csrf_token %} + + + + + {{ site_name }} - {% trans 'Confirmation' %} + {% include "common_libs.html" %} + {% if url %}{% endif %} + + + {% include "_header.html" %} +
+

{% trans 'Are you sure to delete?' %}

+
+
{% include "_item_card.html" with item=item %}
+ {% if item.is_deleted %} +

+ 条目已被删除 +

+ {% endif %} + {% if item.child_items %} +

+ 条目下已有子项 +

+ {% endif %} + {% if item.merged_to_item %} +

+ 条目已被合并到其他条目 +

+ {% endif %} + {% if item.journal_exists %} +

+ 条目已被用户标记过 +

+ {% endif %} +
+ + {% csrf_token %} + + + + +
+ {% include "_footer.html" %} + + diff --git a/catalog/templates/catalog_merge.html b/catalog/templates/catalog_merge.html new file mode 100644 index 00000000..135d9761 --- /dev/null +++ b/catalog/templates/catalog_merge.html @@ -0,0 +1,94 @@ +{% load static %} +{% load i18n %} +{% load l10n %} +{% load admin_url %} +{% load mastodon %} +{% load oauth_token %} +{% load truncate %} +{% load thumb %} + + + + + + {{ site_name }} - {% trans 'Confirmation' %} + {% include "common_libs.html" %} + {% if url %}{% endif %} + + + {% include "_header.html" %} +
+

+ {% if new_item %} + {% trans 'Are you sure to merge?' %} + {% else %} + {% trans 'Are you sure to cancel merge?' %} + {% endif %} +

+
+
{% include "_item_card.html" with item=item %}
+ {% if item.is_deleted %} +

+ 条目已被删除 +

+ {% endif %} + {% if item.child_items %} +

+ 条目下已有子项 +

+ {% endif %} + {% if item.merged_to_item %} +

+ 条目已被合并到其他条目 +

+ {% endif %} + {% if item.journal_exists %} +

+ 条目已被用户标记过 +

+ {% endif %} + {% if new_item %} +
+
+ + +
+
+
{% include "_item_card.html" with item=new_item %}
+ {% if new_item.is_deleted %} +

+ 条目已被删除 +

+ {% endif %} + {% if new_item.child_items %} +

+ 条目下已有子项 +

+ {% endif %} + {% if new_item.merged_to_item %} +

+ 条目已被合并到其他条目 +

+ {% endif %} + {% if new_item.journal_exists %} +

+ 条目已被用户标记过 +

+ {% endif %} + {% endif %} +
+
+ {% csrf_token %} + + + + +
+
+{% include "_footer.html" %} + + diff --git a/catalog/views_edit.py b/catalog/views_edit.py index 4fd69905..0e7eac10 100644 --- a/catalog/views_edit.py +++ b/catalog/views_edit.py @@ -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: diff --git a/common/static/scss/_common.scss b/common/static/scss/_common.scss index 4d6092aa..11c4748d 100644 --- a/common/static/scss/_common.scss +++ b/common/static/scss/_common.scss @@ -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;