mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-15 21:31:26 +00:00
Store user that added link
This commit is contained in:
parent
6c78a7b6ef
commit
34f375c53c
4 changed files with 9 additions and 4 deletions
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
{% block modal-body %}
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ book.id }}">
|
||||
<input type="hidden" name="added_by" value="{{ request.user.id }}">
|
||||
|
||||
<p class="notification">
|
||||
{% trans "Links from unknown domains will need to be approved by a moderator before they are added." %}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue