forked from mirrors/bookwyrm
Adds migration
This commit is contained in:
parent
37e03e8993
commit
cef46a1827
6 changed files with 111 additions and 2 deletions
|
@ -195,6 +195,8 @@ class EditionForm(CustomForm):
|
|||
"shelves",
|
||||
"connector",
|
||||
"search_vector",
|
||||
"links",
|
||||
"file_links",
|
||||
]
|
||||
|
||||
|
||||
|
@ -207,6 +209,7 @@ class AuthorForm(CustomForm):
|
|||
"created_date",
|
||||
"updated_date",
|
||||
"search_vector",
|
||||
"links",
|
||||
]
|
||||
|
||||
|
||||
|
|
105
bookwyrm/migrations/0107_auto_20211007_2253.py
Normal file
105
bookwyrm/migrations/0107_auto_20211007_2253.py
Normal file
|
@ -0,0 +1,105 @@
|
|||
# Generated by Django 3.2.5 on 2021-10-07 22:53
|
||||
|
||||
import bookwyrm.models.activitypub_mixin
|
||||
import bookwyrm.models.fields
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("bookwyrm", "0106_user_preferred_language"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="Link",
|
||||
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],
|
||||
),
|
||||
),
|
||||
("url", bookwyrm.models.fields.CharField(max_length=255)),
|
||||
("name", bookwyrm.models.fields.CharField(max_length=255)),
|
||||
],
|
||||
options={
|
||||
"abstract": False,
|
||||
},
|
||||
bases=(bookwyrm.models.activitypub_mixin.CollectionItemMixin, models.Model),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="user",
|
||||
name="preferred_language",
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
choices=[
|
||||
("en-us", "English"),
|
||||
("de-de", "Deutsch (German)"),
|
||||
("es", "Español (Spanish)"),
|
||||
("fr-fr", "Français (French)"),
|
||||
("zh-hans", "简体中文 (Simplified Chinese)"),
|
||||
("zh-hant", "繁體中文 (Traditional Chinese)"),
|
||||
],
|
||||
max_length=255,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="FileLink",
|
||||
fields=[
|
||||
(
|
||||
"link_ptr",
|
||||
models.OneToOneField(
|
||||
auto_created=True,
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
parent_link=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
to="bookwyrm.link",
|
||||
),
|
||||
),
|
||||
("filetype", bookwyrm.models.fields.CharField(max_length=5)),
|
||||
(
|
||||
"filetype_description",
|
||||
bookwyrm.models.fields.CharField(max_length=100),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"abstract": False,
|
||||
},
|
||||
bases=("bookwyrm.link",),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="author",
|
||||
name="links",
|
||||
field=bookwyrm.models.fields.ManyToManyField(to="bookwyrm.Link"),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="book",
|
||||
name="links",
|
||||
field=bookwyrm.models.fields.ManyToManyField(to="bookwyrm.Link"),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="book",
|
||||
name="file_links",
|
||||
field=bookwyrm.models.fields.ManyToManyField(
|
||||
related_name="editions", to="bookwyrm.FileLink"
|
||||
),
|
||||
),
|
||||
]
|
|
@ -4,6 +4,7 @@ import sys
|
|||
|
||||
from .book import Book, Work, Edition, BookDataModel
|
||||
from .author import Author
|
||||
from .link import Link, FileLink
|
||||
from .connector import Connector
|
||||
|
||||
from .shelf import Shelf, ShelfBook
|
||||
|
|
|
@ -105,7 +105,7 @@ class Book(BookDataModel):
|
|||
|
||||
objects = InheritanceManager()
|
||||
field_tracker = FieldTracker(fields=["authors", "title", "subtitle", "cover"])
|
||||
file_links = fields.ManyToManyField("FileLink")
|
||||
file_links = fields.ManyToManyField("FileLink", related_name="editions")
|
||||
|
||||
if ENABLE_THUMBNAIL_GENERATION:
|
||||
cover_bw_book_xsmall_webp = ImageSpecField(
|
||||
|
|
|
@ -3,6 +3,7 @@ from .activitypub_mixin import CollectionItemMixin
|
|||
from .base_model import BookWyrmModel
|
||||
from . import fields
|
||||
|
||||
|
||||
class Link(CollectionItemMixin, BookWyrmModel):
|
||||
"""a link to a website"""
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ from .isbn import Isbn
|
|||
from .landing import About, Home, Landing
|
||||
from .list import Lists, SavedLists, List, Curate, UserLists
|
||||
from .list import save_list, unsave_list, delete_list
|
||||
from .link import Link, FileLink
|
||||
from .login import Login, Logout
|
||||
from .notifications import Notifications
|
||||
from .outbox import Outbox
|
||||
|
|
Loading…
Reference in a new issue