From 2ca41a0b118541dbc520f5c46ab7c5921aed1208 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 12 Jan 2022 09:16:24 -0800 Subject: [PATCH] Renames add link view --- bookwyrm/tests/views/books/test_links.py | 8 ++++---- bookwyrm/urls.py | 8 ++------ bookwyrm/views/__init__.py | 2 +- bookwyrm/views/books/links.py | 13 ++++--------- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/bookwyrm/tests/views/books/test_links.py b/bookwyrm/tests/views/books/test_links.py index bdd9aaf42..9e051926e 100644 --- a/bookwyrm/tests/views/books/test_links.py +++ b/bookwyrm/tests/views/books/test_links.py @@ -48,9 +48,9 @@ class LinkViews(TestCase): models.SiteSettings.objects.create() - def test_edit_link_page(self): + def test_add_link_page(self): """there are so many views, this just makes sure it LOADS""" - view = views.FileLink.as_view() + view = views.AddFileLink.as_view() request = self.factory.get("") request.user = self.local_user result = view(request, self.book.id) @@ -59,9 +59,9 @@ class LinkViews(TestCase): self.assertEqual(result.status_code, 200) - def test_edit_link_post(self, *_): + def test_add_link_post(self, *_): """there are so many views, this just makes sure it LOADS""" - view = views.FileLink.as_view() + view = views.AddFileLink.as_view() form = forms.FileLinkForm() form.data["url"] = "https://www.example.com" form.data["filetype"] = "HTML" diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 20092106f..e1dd65295 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -168,6 +168,7 @@ urlpatterns = [ views.LinkDomain.as_view(), name="settings-link-domain", ), + # pylint: disable=line-too-long re_path( r"^setting/link-domains/(?P(pending|approved|blocked))/(?P\d+)/?$", views.LinkDomain.as_view(), @@ -468,12 +469,7 @@ urlpatterns = [ views.add_description, name="add-description", ), - re_path(rf"{BOOK_PATH}/filelink/?$", views.FileLink.as_view(), name="file-link"), - re_path( - rf"{BOOK_PATH}/filelink/(?P\d+)/?$", - views.FileLink.as_view(), - name="file-link", - ), + re_path(rf"{BOOK_PATH}/filelink/?$", views.AddFileLink.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"), re_path( diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index eb9eefe2e..781bc52a9 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -37,7 +37,7 @@ from .books.books import ( 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 +from .books.links import AddFileLink # landing from .landing.about import about, privacy, conduct diff --git a/bookwyrm/views/books/links.py b/bookwyrm/views/books/links.py index 1b6818bae..e83ba599d 100644 --- a/bookwyrm/views/books/links.py +++ b/bookwyrm/views/books/links.py @@ -7,7 +7,6 @@ from django.views import View from django.utils.decorators import method_decorator from bookwyrm import forms, models -from bookwyrm.activitypub import ActivitypubResponse # pylint: disable=no-self-use @@ -15,18 +14,14 @@ from bookwyrm.activitypub import ActivitypubResponse @method_decorator( permission_required("bookwyrm.edit_book", raise_exception=True), name="dispatch" ) -class FileLink(View): +class AddFileLink(View): """a book! this is the stuff""" - def get(self, request, book_id=None, link_id=None): - """info about a book""" - link = get_object_or_404(models.FileLink, id=link_id) if link_id else None - if not book_id: - return ActivitypubResponse(link.to_activity()) - + def get(self, request, book_id): + """Create link form""" book = get_object_or_404(models.Edition, id=book_id) data = { - "file_link_form": forms.FileLinkForm(instance=link), + "file_link_form": forms.FileLinkForm(), "book": book, } return TemplateResponse(request, "book/file_link_page.html", data)