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