forked from mirrors/bookwyrm
Add user attribution to links and domains
This commit is contained in:
parent
93fead47ef
commit
6c78a7b6ef
3 changed files with 26 additions and 1 deletions
|
@ -300,6 +300,7 @@ class Link(ActivityObject):
|
|||
name: str = None
|
||||
mediaType: str = None
|
||||
id: str = None
|
||||
attributedTo: str = None
|
||||
type: str = "Link"
|
||||
|
||||
def serialize(self, **kwargs):
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
# Generated by Django 3.2.10 on 2022-01-09 22:10
|
||||
# Generated by Django 3.2.10 on 2022-01-10 21:20
|
||||
|
||||
import bookwyrm.models.activitypub_mixin
|
||||
import bookwyrm.models.fields
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
@ -49,6 +50,15 @@ class Migration(migrations.Migration):
|
|||
),
|
||||
),
|
||||
("name", models.CharField(max_length=100)),
|
||||
(
|
||||
"reported_by",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"abstract": False,
|
||||
|
@ -77,6 +87,14 @@ class Migration(migrations.Migration):
|
|||
),
|
||||
),
|
||||
("url", bookwyrm.models.fields.URLField(max_length=255)),
|
||||
(
|
||||
"added_by",
|
||||
bookwyrm.models.fields.ForeignKey(
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
(
|
||||
"domain",
|
||||
models.ForeignKey(
|
||||
|
|
|
@ -22,6 +22,9 @@ 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
|
||||
|
@ -66,6 +69,9 @@ class LinkDomain(BookWyrmModel):
|
|||
domain = models.CharField(max_length=255, unique=True)
|
||||
status = models.CharField(max_length=50, choices=StatusChoices, default="pending")
|
||||
name = models.CharField(max_length=100)
|
||||
reported_by = models.ForeignKey(
|
||||
"User", blank=True, null=True, on_delete=models.SET_NULL
|
||||
)
|
||||
|
||||
def raise_not_editable(self, viewer):
|
||||
if viewer.has_perm("moderate_post"):
|
||||
|
|
Loading…
Reference in a new issue