forked from mirrors/bookwyrm
Delete view
This commit is contained in:
parent
ebc451fdd2
commit
4cf3f378ef
4 changed files with 41 additions and 9 deletions
|
@ -53,7 +53,10 @@
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<button class="button is-danger is-light">Delete link</button>
|
<form name="delete-link-{{ link.id }}" class="control" method="post" action="{% url 'file-link' book.id link.id %}">
|
||||||
|
{% csrf_token %}
|
||||||
|
<button class="button is-danger is-light" type="submit">Delete link</button>
|
||||||
|
</form>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -64,6 +67,16 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% url 'file-link-add' book.id as fallback_url %}
|
||||||
|
<form name="add-link" method="get" action="{{ fallback_url }}">
|
||||||
|
<button class="button" type="submit" data-modal-open="add-links">
|
||||||
|
<span class="icon icon-plus m-0-mobile" aria-hidden="true"></span>
|
||||||
|
<span class="is-sr-only-mobile">
|
||||||
|
{% trans "Add link to file" %}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -11,13 +11,15 @@
|
||||||
{% if can_edit_book %}
|
{% if can_edit_book %}
|
||||||
<div class="column is-narrow">
|
<div class="column is-narrow">
|
||||||
{% url 'file-link-add' book.id as fallback_url %}
|
{% url 'file-link-add' book.id as fallback_url %}
|
||||||
<button class="button is-small" type="button" data-modal-open="add-links">
|
<form name="add-link" method="get" action="{{ fallback_url }}">
|
||||||
<span class="icon icon-plus">
|
<button class="button is-small" type="submit" data-modal-open="add-links">
|
||||||
<span class="is-sr-only">
|
<span class="icon icon-plus">
|
||||||
{% trans "Add link to copy" %}
|
<span class="is-sr-only">
|
||||||
|
{% trans "Add link to file" %}
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</button>
|
||||||
</button>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</header>
|
</header>
|
||||||
|
|
|
@ -469,8 +469,19 @@ urlpatterns = [
|
||||||
views.add_description,
|
views.add_description,
|
||||||
name="add-description",
|
name="add-description",
|
||||||
),
|
),
|
||||||
re_path(rf"{BOOK_PATH}/filelink/?$", views.BookFileLinks.as_view(), name="file-link"),
|
re_path(
|
||||||
re_path(rf"{BOOK_PATH}/filelink/add/?$", views.AddFileLink.as_view(), name="file-link-add"),
|
rf"{BOOK_PATH}/filelink/?$", views.BookFileLinks.as_view(), name="file-link"
|
||||||
|
),
|
||||||
|
re_path(
|
||||||
|
rf"{BOOK_PATH}/filelink/(?P<link_id>\d+)/delete/?$",
|
||||||
|
views.BookFileLinks.as_view(),
|
||||||
|
name="file-link",
|
||||||
|
),
|
||||||
|
re_path(
|
||||||
|
rf"{BOOK_PATH}/filelink/add/?$",
|
||||||
|
views.AddFileLink.as_view(),
|
||||||
|
name="file-link-add",
|
||||||
|
),
|
||||||
re_path(r"^resolve-book/?$", views.resolve_book, name="resolve-book"),
|
re_path(r"^resolve-book/?$", views.resolve_book, name="resolve-book"),
|
||||||
re_path(r"^switch-edition/?$", views.switch_edition, name="switch-edition"),
|
re_path(r"^switch-edition/?$", views.switch_edition, name="switch-edition"),
|
||||||
re_path(
|
re_path(
|
||||||
|
|
|
@ -18,6 +18,12 @@ class BookFileLinks(View):
|
||||||
book = get_object_or_404(models.Edition, id=book_id)
|
book = get_object_or_404(models.Edition, id=book_id)
|
||||||
return TemplateResponse(request, "book/edit_links.html", {"book": book})
|
return TemplateResponse(request, "book/edit_links.html", {"book": book})
|
||||||
|
|
||||||
|
def post(self, request, book_id, link_id):
|
||||||
|
"""delete link"""
|
||||||
|
link = get_object_or_404(models.FileLink, id=link_id, book=book_id)
|
||||||
|
link.delete()
|
||||||
|
return self.get(request, book_id)
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(login_required, name="dispatch")
|
@method_decorator(login_required, name="dispatch")
|
||||||
@method_decorator(
|
@method_decorator(
|
||||||
|
|
Loading…
Reference in a new issue