1 from django.db import models
2 from django.utils.translation import gettext_lazy as _
3 from .constants import WIKIDATA
4 from .wikidata import WikidataMixin
7 class Author(WikidataMixin, models.Model):
8 slug = models.SlugField(null=True, blank=True, unique=True)
9 first_name = models.CharField(max_length=255, blank=True)
10 last_name = models.CharField(max_length=255, blank=True)
11 year_of_death = models.SmallIntegerField(null=True, blank=True)
12 status = models.PositiveSmallIntegerField(
22 notes = models.TextField(blank=True)
23 priority = models.PositiveSmallIntegerField(
24 default=0, choices=[(0, _("Low")), (1, _("Medium")), (2, _("High"))]
28 first_name = WIKIDATA.GIVEN_NAME
29 last_name = WIKIDATA.LAST_NAME
30 year_of_death = WIKIDATA.DATE_OF_DEATH
34 return f"{self.first_name} {self.last_name}"
37 class Book(WikidataMixin, models.Model):
38 slug = models.SlugField(max_length=255, blank=True, null=True, unique=True)
39 authors = models.ManyToManyField(Author, blank=True)
40 translators = models.ManyToManyField(
42 related_name="translated_book_set",
43 related_query_name="translated_book",
46 title = models.CharField(max_length=255, blank=True)
47 language = models.CharField(max_length=3, blank=True)
48 based_on = models.ForeignKey(
49 "self", models.PROTECT, related_name="translation", null=True, blank=True
51 scans_source = models.CharField(max_length=255, blank=True)
52 text_source = models.CharField(max_length=255, blank=True)
53 notes = models.TextField(blank=True)
54 priority = models.PositiveSmallIntegerField(
55 default=0, choices=[(0, _("Low")), (1, _("Medium")), (2, _("High"))]
59 authors = WIKIDATA.AUTHOR
60 translators = WIKIDATA.TRANSLATOR
61 title = WIKIDATA.TITLE
62 language = WIKIDATA.LANGUAGE
63 based_on = WIKIDATA.BASED_ON