2021-03-08 11:49:10 -05:00
|
|
|
""" database schema for info about authors """
|
2021-06-23 19:14:59 -04:00
|
|
|
from django.contrib.postgres.indexes import GinIndex
|
2020-11-27 17:54:08 -05:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
from bookwyrm import activitypub
|
2020-11-28 16:40:09 -05:00
|
|
|
from bookwyrm.settings import DOMAIN
|
2020-11-27 17:54:08 -05:00
|
|
|
|
2020-12-21 15:17:18 -05:00
|
|
|
from .book import BookDataModel
|
2020-11-30 17:40:26 -05:00
|
|
|
from . import fields
|
2020-11-27 17:54:08 -05:00
|
|
|
|
|
|
|
|
2020-12-21 15:17:18 -05:00
|
|
|
class Author(BookDataModel):
|
2021-04-26 12:15:42 -04:00
|
|
|
"""basic biographic info"""
|
2021-03-08 11:49:10 -05:00
|
|
|
|
2020-12-12 21:06:48 -05:00
|
|
|
wikipedia_link = fields.CharField(
|
2021-03-08 11:49:10 -05:00
|
|
|
max_length=255, blank=True, null=True, deduplication_field=True
|
|
|
|
)
|
2021-04-06 20:46:06 -04:00
|
|
|
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
|
|
|
|
)
|
2020-11-27 17:54:08 -05:00
|
|
|
# idk probably other keys would be useful here?
|
2020-11-30 17:40:26 -05:00
|
|
|
born = fields.DateTimeField(blank=True, null=True)
|
|
|
|
died = fields.DateTimeField(blank=True, null=True)
|
2021-11-21 16:47:12 -05:00
|
|
|
name = fields.CharField(max_length=255)
|
2020-11-30 17:40:26 -05:00
|
|
|
aliases = fields.ArrayField(
|
2020-11-27 17:54:08 -05:00
|
|
|
models.CharField(max_length=255), blank=True, default=list
|
|
|
|
)
|
2020-12-16 19:47:05 -05:00
|
|
|
bio = fields.HtmlField(null=True, blank=True)
|
2020-11-27 17:54:08 -05:00
|
|
|
|
2020-11-28 16:40:09 -05:00
|
|
|
def get_remote_id(self):
|
2021-04-26 12:15:42 -04:00
|
|
|
"""editions and works both use "book" instead of model_name"""
|
2021-09-18 14:32:00 -04:00
|
|
|
return f"https://{DOMAIN}/author/{self.id}"
|
2020-11-28 16:40:09 -05:00
|
|
|
|
2020-11-27 17:54:08 -05:00
|
|
|
activity_serializer = activitypub.Author
|
2021-06-23 19:14:59 -04:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
"""sets up postgres GIN index field"""
|
|
|
|
|
|
|
|
indexes = (GinIndex(fields=["search_vector"]),)
|