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 gazeta_link = models.CharField(max_length=255, blank=True)
24 culturepl_link = models.CharField(max_length=255, blank=True)
25 description = models.TextField(blank=True)
26 priority = models.PositiveSmallIntegerField(
27 default=0, choices=[(0, _("Low")), (1, _("Medium")), (2, _("High"))]
31 first_name = WIKIDATA.GIVEN_NAME
32 last_name = WIKIDATA.LAST_NAME
33 year_of_death = WIKIDATA.DATE_OF_DEATH
37 return f"{self.first_name} {self.last_name}"
40 class Book(WikidataMixin, models.Model):
41 slug = models.SlugField(max_length=255, blank=True, null=True, unique=True)
42 authors = models.ManyToManyField(Author, blank=True)
43 translators = models.ManyToManyField(
45 related_name="translated_book_set",
46 related_query_name="translated_book",
49 title = models.CharField(max_length=255, blank=True)
50 language = models.CharField(max_length=255, blank=True)
51 based_on = models.ForeignKey(
52 "self", models.PROTECT, related_name="translation", null=True, blank=True
54 scans_source = models.CharField(max_length=255, blank=True)
55 text_source = models.CharField(max_length=255, blank=True)
56 notes = models.TextField(blank=True)
57 priority = models.PositiveSmallIntegerField(
58 default=0, choices=[(0, _("Low")), (1, _("Medium")), (2, _("High"))]
60 pd_year = models.IntegerField(null=True, blank=True)
63 authors = WIKIDATA.AUTHOR
64 translators = WIKIDATA.TRANSLATOR
65 title = WIKIDATA.TITLE
66 language = WIKIDATA.LANGUAGE
67 based_on = WIKIDATA.BASED_ON