diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index 5ad365011..e08f3a3a5 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -225,7 +225,7 @@ class LinkDomainForm(CustomForm): class FileLinkForm(CustomForm): class Meta: model = models.FileLink - fields = ["url", "filetype", "book"] + fields = ["url", "filetype", "book", "added_by"] class EditionForm(CustomForm): diff --git a/bookwyrm/models/link.py b/bookwyrm/models/link.py index 22241dddf..3e21642f2 100644 --- a/bookwyrm/models/link.py +++ b/bookwyrm/models/link.py @@ -15,6 +15,12 @@ class Link(ActivitypubMixin, BookWyrmModel): """a link to a website""" url = fields.URLField(max_length=255, activitypub_field="href") + added_by = fields.ForeignKey( + "User", + on_delete=models.SET_NULL, + null=True, + activitypub_field="attributedTo" + ) domain = models.ForeignKey( "LinkDomain", on_delete=models.CASCADE, @@ -22,9 +28,6 @@ class Link(ActivitypubMixin, BookWyrmModel): blank=True, related_name="links", ) - added_by = fields.ForeignKey( - "User", on_delete=models.SET_NULL, null=True, activitypub_field="attributedTo" - ) activity_serializer = activitypub.Link reverse_unfurl = True diff --git a/bookwyrm/templates/book/file_link_modal.html b/bookwyrm/templates/book/file_link_modal.html index 04e215574..379f1a077 100644 --- a/bookwyrm/templates/book/file_link_modal.html +++ b/bookwyrm/templates/book/file_link_modal.html @@ -12,6 +12,7 @@ {% block modal-body %} {% csrf_token %} +
{% trans "Links from unknown domains will need to be approved by a moderator before they are added." %} diff --git a/bookwyrm/tests/views/books/test_links.py b/bookwyrm/tests/views/books/test_links.py index 1214e0e2e..1961bde00 100644 --- a/bookwyrm/tests/views/books/test_links.py +++ b/bookwyrm/tests/views/books/test_links.py @@ -66,6 +66,7 @@ class LinkViews(TestCase): form.data["url"] = "https://www.example.com" form.data["filetype"] = "HTML" form.data["book"] = self.book.id + form.data["added_by"] = self.local_user request = self.factory.post("", form.data) request.user = self.local_user