mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 10:01:04 +00:00
Renames add link view
This commit is contained in:
parent
e6d9895854
commit
2ca41a0b11
4 changed files with 11 additions and 20 deletions
|
@ -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"
|
||||
|
|
|
@ -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<status>(pending|approved|blocked))/(?P<domain_id>\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<link_id>\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(
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue