mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-17 21:56:36 +00:00
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
""" database schema for info about authors """
|
|
from django.contrib.postgres.indexes import GinIndex
|
|
from django.db import models
|
|
|
|
from bookwyrm import activitypub
|
|
from bookwyrm.settings import DOMAIN
|
|
|
|
from .book import BookDataModel
|
|
from . import fields
|
|
|
|
|
|
class Author(BookDataModel):
|
|
"""basic biographic info"""
|
|
|
|
wikipedia_link = fields.CharField(
|
|
max_length=255, blank=True, null=True, deduplication_field=True
|
|
)
|
|
isni = fields.CharField(
|
|
max_length=255, blank=True, null=True, deduplication_field=True
|
|
)
|
|
viaf_id = fields.CharField(
|
|
max_length=255, blank=True, null=True, deduplication_field=True
|
|
)
|
|
gutenberg_id = fields.CharField(
|
|
max_length=255, blank=True, null=True, deduplication_field=True
|
|
)
|
|
# idk probably other keys would be useful here?
|
|
born = fields.DateTimeField(blank=True, null=True)
|
|
died = fields.DateTimeField(blank=True, null=True)
|
|
name = fields.CharField(max_length=255, deduplication_field=True)
|
|
aliases = fields.ArrayField(
|
|
models.CharField(max_length=255), blank=True, default=list
|
|
)
|
|
bio = fields.HtmlField(null=True, blank=True)
|
|
|
|
def get_remote_id(self):
|
|
"""editions and works both use "book" instead of model_name"""
|
|
return f"https://{DOMAIN}/author/{self.id}"
|
|
|
|
activity_serializer = activitypub.Author
|
|
|
|
class Meta:
|
|
"""sets up postgres GIN index field"""
|
|
|
|
indexes = (GinIndex(fields=["search_vector"]),)
|