mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-30 05:21:08 +00:00
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>
|
||||
</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>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -64,6 +67,16 @@
|
|||
{% endif %}
|
||||
</table>
|
||||
</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>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -11,13 +11,15 @@
|
|||
{% if can_edit_book %}
|
||||
<div class="column is-narrow">
|
||||
{% 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 }}">
|
||||
<button class="button is-small" type="submit" data-modal-open="add-links">
|
||||
<span class="icon icon-plus">
|
||||
<span class="is-sr-only">
|
||||
{% trans "Add link to copy" %}
|
||||
{% trans "Add link to file" %}
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
</header>
|
||||
|
|
|
@ -469,8 +469,19 @@ urlpatterns = [
|
|||
views.add_description,
|
||||
name="add-description",
|
||||
),
|
||||
re_path(rf"{BOOK_PATH}/filelink/?$", views.BookFileLinks.as_view(), name="file-link"),
|
||||
re_path(rf"{BOOK_PATH}/filelink/add/?$", views.AddFileLink.as_view(), name="file-link-add"),
|
||||
re_path(
|
||||
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"^switch-edition/?$", views.switch_edition, name="switch-edition"),
|
||||
re_path(
|
||||
|
|
|
@ -18,6 +18,12 @@ class BookFileLinks(View):
|
|||
book = get_object_or_404(models.Edition, id=book_id)
|
||||
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(
|
||||
|
|
Loading…
Reference in a new issue