{{ file_link_form.name }}
+ {% include 'snippets/form_errors.html' with errors_list=file_link_form.name.errors id="desc_name" %}
-
+
+ {% include 'snippets/form_errors.html' with errors_list=file_link_form.url.errors id="desc_url" %}
+ {% include 'snippets/form_errors.html' with errors_list=file_link_form.filetype.errors id="desc_filetype" %}
diff --git a/bookwyrm/views/books/links.py b/bookwyrm/views/books/links.py
index 722d0545a..949c807f5 100644
--- a/bookwyrm/views/books/links.py
+++ b/bookwyrm/views/books/links.py
@@ -28,10 +28,11 @@ class FileLink(View):
return TemplateResponse(request, "book/file_link_page.html", data)
@transaction.atomic
- def post(self, request, book_id):
+ def post(self, request, book_id, link_id=None):
"""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)
+ link = get_object_or_404(models.FileLink, id=link_id) if link_id else None
+ form = forms.FileLinkForm(request.POST, instance=link)
if not form.is_valid():
data = {"file_link_form": form, "book": book}
return TemplateResponse(request, "book/file_link_page.html", data)