reassign tvseason to show.
This commit is contained in:
parent
433d0e6df1
commit
27fdda3b21
2 changed files with 3 additions and 3 deletions
|
@ -76,7 +76,7 @@
|
|||
{% if not item.show or request.user.is_superuser %}
|
||||
<div class="action-panel__label">{% trans '将本季关联到电视剧' %} </div>
|
||||
<div class="action-panel__button-group">
|
||||
<form method="post" action="{% url 'catalog:assign_parent' item.url_path item.uuid %}" onsubmit="return confirm('本操作不可撤销。确认合并吗?');">
|
||||
<form method="post" action="{% url 'catalog:assign_parent' item.url_path item.uuid %}" onsubmit="return confirm('本操作不可撤销。确认关联吗?');">
|
||||
{% csrf_token %}
|
||||
<input type="url" name="parent_item_url" placeholder="目标条目URL" value="{{ item.show.absolute_url }}" required><br>
|
||||
<input class="button" type="submit" value="{% trans '提交' %}">
|
||||
|
|
|
@ -230,13 +230,13 @@ def assign_parent(request, item_path, item_uuid):
|
|||
if request.method != "POST":
|
||||
raise BadRequest()
|
||||
item = get_object_or_404(Item, uid=get_uuid_or_404(item_uuid))
|
||||
if not request.user.is_superuser and not item.deletable:
|
||||
raise PermissionDenied()
|
||||
new_item = Item.get_by_url(request.POST.get("parent_item_url"))
|
||||
if not new_item or new_item.is_deleted or new_item.merged_to_item_id:
|
||||
raise BadRequest("Can't assign parent to a deleted or redirected item")
|
||||
if item.__class__ != TVSeason or new_item.__class__ != TVShow:
|
||||
raise BadRequest("Can't assign parent for this item")
|
||||
if not request.user.is_superuser and item.show:
|
||||
raise PermissionDenied()
|
||||
_logger.warn(f"{request.user} assign {item} to {new_item}")
|
||||
item.show = new_item
|
||||
item.save(update_fields=["show"])
|
||||
|
|
Loading…
Add table
Reference in a new issue