mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-11 10:46:37 +00:00
Adds noscript fallback for links modal
This commit is contained in:
parent
4f576b77a0
commit
cc3db31db9
6 changed files with 22 additions and 24 deletions
|
@ -361,8 +361,9 @@
|
|||
|
||||
{% if can_edit_book %}
|
||||
{% trans "Add link to copy" as button_text %}
|
||||
{% include 'snippets/toggle/toggle_button.html' with text=button_text controls_text="edit_file_links" controls_uid=book.id focus="modal_title_edit_file_links" class="is-small" icon_with_text="plus" %}
|
||||
{% include 'book/file_links_modal.html' with book=book controls_text="edit_file_links" controls_uid=book.id %}
|
||||
{% url 'file-link' book.id as fallback_url %}
|
||||
{% include 'snippets/toggle/toggle_button.html' with text=button_text controls_text="edit_file_links" controls_uid=book.id focus="modal_title_edit_file_links" class="is-small" icon_with_text="plus" fallback_url=fallback_url %}
|
||||
{% include 'book/file_link_modal.html' with book=book controls_text="edit_file_links" controls_uid=book.id %}
|
||||
{% endif %}
|
||||
</section>
|
||||
</div>
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block modal-form-open %}
|
||||
<form name="add-link" method="POST" action="{% url 'add-file-link' book.id %}">
|
||||
<form name="add-link" method="POST" action="{% url 'file-link' book.id %}">
|
||||
{% endblock %}
|
||||
|
||||
{% block modal-body %}
|
||||
{% csrf_token %}
|
||||
<div class="field">
|
||||
<label class="label" for="id_url">{% trans "Description:" %}</label>
|
||||
<label class="label" for="id_url">{% trans "Name:" %}</label>
|
||||
{{ file_link_form.name }}
|
||||
</div>
|
||||
|
10
bookwyrm/templates/book/file_link_page.html
Normal file
10
bookwyrm/templates/book/file_link_page.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
{% extends 'layout.html' %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block title %}
|
||||
{% trans "File Links" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% include "book/file_link_modal.html" with book=book active=True static=True %}
|
||||
{% endblock %}
|
|
@ -433,7 +433,12 @@ urlpatterns = [
|
|||
name="add-description",
|
||||
),
|
||||
re_path(
|
||||
r"^add-file-link/(?P<book_id>\d+)/?$", views.add_file_link, name="add-file-link"
|
||||
rf"{BOOK_PATH}/file-link/?$", views.FileLink.as_view(), name="file-link"
|
||||
),
|
||||
re_path(
|
||||
rf"{BOOK_PATH}/file-link/(?P<link_id>\d+)/?$",
|
||||
views.FileLink.as_view(),
|
||||
name="file-link"
|
||||
),
|
||||
re_path(r"^resolve-book/?$", views.resolve_book, name="resolve-book"),
|
||||
re_path(r"^switch-edition/?$", views.switch_edition, name="switch-edition"),
|
||||
|
|
|
@ -33,11 +33,11 @@ from .books.books import (
|
|||
upload_cover,
|
||||
add_description,
|
||||
resolve_book,
|
||||
add_file_link,
|
||||
)
|
||||
from .books.books import update_book_from_remote
|
||||
from .books.edit_book import EditBook, ConfirmEditBook
|
||||
from .books.editions import Editions, switch_edition
|
||||
from .books.links import FileLink
|
||||
|
||||
# landing
|
||||
from .landing.landing import About, Home, Landing
|
||||
|
|
|
@ -196,21 +196,3 @@ def update_book_from_remote(request, book_id, connector_identifier):
|
|||
connector.update_book_from_remote(book)
|
||||
|
||||
return redirect("book", book.id)
|
||||
|
||||
|
||||
@login_required
|
||||
@require_POST
|
||||
@permission_required("bookwyrm.edit_book", raise_exception=True)
|
||||
@transaction.atomic
|
||||
def add_file_link(request, book_id):
|
||||
"""Add a link to a copy of the book you can read"""
|
||||
book = get_object_or_404(models.Book.objects.select_subclasses(), id=book_id)
|
||||
form = forms.FileLinkForm(request.POST)
|
||||
if not form.is_valid():
|
||||
return redirect("book", book.id)
|
||||
|
||||
link = form.save()
|
||||
book.file_links.add(link)
|
||||
book.last_edited_by = request.user
|
||||
book.save()
|
||||
return redirect("book", book.id)
|
||||
|
|
Loading…
Reference in a new issue