forked from mirrors/bookwyrm
Adds link domain table
This commit is contained in:
parent
4931e5cad2
commit
bae355e8d2
2 changed files with 66 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 3.2.5 on 2021-12-16 00:20
|
# Generated by Django 3.2.10 on 2022-01-09 21:16
|
||||||
|
|
||||||
import bookwyrm.models.activitypub_mixin
|
import bookwyrm.models.activitypub_mixin
|
||||||
import bookwyrm.models.fields
|
import bookwyrm.models.fields
|
||||||
|
@ -9,7 +9,7 @@ import django.db.models.deletion
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
("bookwyrm", "0120_list_embed_key"),
|
("bookwyrm", "0125_alter_user_preferred_language"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
@ -36,13 +36,53 @@ class Migration(migrations.Migration):
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
("url", bookwyrm.models.fields.URLField(max_length=255)),
|
("url", bookwyrm.models.fields.URLField(max_length=255)),
|
||||||
("name", bookwyrm.models.fields.CharField(max_length=255)),
|
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
"abstract": False,
|
"abstract": False,
|
||||||
},
|
},
|
||||||
bases=(bookwyrm.models.activitypub_mixin.ActivitypubMixin, models.Model),
|
bases=(bookwyrm.models.activitypub_mixin.ActivitypubMixin, models.Model),
|
||||||
),
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="LinkDomain",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.AutoField(
|
||||||
|
auto_created=True,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
verbose_name="ID",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("created_date", models.DateTimeField(auto_now_add=True)),
|
||||||
|
("updated_date", models.DateTimeField(auto_now=True)),
|
||||||
|
(
|
||||||
|
"remote_id",
|
||||||
|
bookwyrm.models.fields.RemoteIdField(
|
||||||
|
max_length=255,
|
||||||
|
null=True,
|
||||||
|
validators=[bookwyrm.models.fields.validate_remote_id],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("domain", models.CharField(max_length=255)),
|
||||||
|
(
|
||||||
|
"status",
|
||||||
|
models.CharField(
|
||||||
|
choices=[
|
||||||
|
("approved", "Approved"),
|
||||||
|
("blocked", "Blocked"),
|
||||||
|
("pending", "Pending"),
|
||||||
|
],
|
||||||
|
default="pending",
|
||||||
|
max_length=50,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("name", models.CharField(max_length=100)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
"abstract": False,
|
||||||
|
},
|
||||||
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name="FileLink",
|
name="FileLink",
|
||||||
fields=[
|
fields=[
|
||||||
|
@ -60,7 +100,7 @@ class Migration(migrations.Migration):
|
||||||
("filetype", bookwyrm.models.fields.CharField(max_length=5)),
|
("filetype", bookwyrm.models.fields.CharField(max_length=5)),
|
||||||
(
|
(
|
||||||
"book",
|
"book",
|
||||||
bookwyrm.models.fields.ForeignKey(
|
models.ForeignKey(
|
||||||
null=True,
|
null=True,
|
||||||
on_delete=django.db.models.deletion.CASCADE,
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
related_name="file_links",
|
related_name="file_links",
|
|
@ -1,5 +1,6 @@
|
||||||
""" outlink data """
|
""" outlink data """
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from bookwyrm import activitypub
|
from bookwyrm import activitypub
|
||||||
from .activitypub_mixin import ActivitypubMixin
|
from .activitypub_mixin import ActivitypubMixin
|
||||||
|
@ -11,7 +12,6 @@ class Link(ActivitypubMixin, BookWyrmModel):
|
||||||
"""a link to a website"""
|
"""a link to a website"""
|
||||||
|
|
||||||
url = fields.URLField(max_length=255, activitypub_field="href")
|
url = fields.URLField(max_length=255, activitypub_field="href")
|
||||||
name = fields.CharField(max_length=255)
|
|
||||||
|
|
||||||
activity_serializer = activitypub.Link
|
activity_serializer = activitypub.Link
|
||||||
reverse_unfurl = True
|
reverse_unfurl = True
|
||||||
|
@ -31,3 +31,24 @@ class FileLink(Link):
|
||||||
"Book", on_delete=models.CASCADE, related_name="file_links", null=True
|
"Book", on_delete=models.CASCADE, related_name="file_links", null=True
|
||||||
)
|
)
|
||||||
filetype = fields.CharField(max_length=5, activitypub_field="mediaType")
|
filetype = fields.CharField(max_length=5, activitypub_field="mediaType")
|
||||||
|
|
||||||
|
|
||||||
|
StatusChoices = [
|
||||||
|
("approved", _("Approved")),
|
||||||
|
("blocked", _("Blocked")),
|
||||||
|
("pending", _("Pending")),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class LinkDomain(BookWyrmModel):
|
||||||
|
"""List of domains used in links"""
|
||||||
|
|
||||||
|
domain = models.CharField(max_length=255)
|
||||||
|
status = models.CharField(max_length=50, choices=StatusChoices, default="pending")
|
||||||
|
name = models.CharField(max_length=100)
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
"""set a default name"""
|
||||||
|
if not self.name:
|
||||||
|
self.name = self.domain
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
|
Loading…
Reference in a new issue