2020-11-27 17:54:08 -05:00
|
|
|
''' database schema for info about authors '''
|
|
|
|
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):
|
2020-11-27 17:54:08 -05:00
|
|
|
''' basic biographic info '''
|
2020-12-12 21:06:48 -05:00
|
|
|
wikipedia_link = 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)
|
2020-12-20 16:31:11 -05:00
|
|
|
name = fields.CharField(max_length=255, deduplication_field=True)
|
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):
|
|
|
|
''' editions and works both use "book" instead of model_name '''
|
2020-11-28 20:29:03 -05:00
|
|
|
return 'https://%s/author/%s' % (DOMAIN, self.id)
|
2020-11-28 16:40:09 -05:00
|
|
|
|
2020-11-27 17:54:08 -05:00
|
|
|
activity_serializer = activitypub.Author
|