# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
from django.contrib import admin
-from django.utils.html import escape
+from django.utils.html import escape, format_html
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
from admin_numeric_filter.admin import RangeNumericFilter, NumericFilterModelAdmin
"wikidata_link",
"slug",
]
- list_filter = ["year_of_death", "priority", "collections", "status", "gender", "nationality"]
+ list_display_links = [
+ "first_name", "last_name"
+ ]
+ list_filter = [
+ ("year_of_death", RangeNumericFilter),
+ "priority",
+ "collections",
+ "status",
+ "gender",
+ "nationality",
+ ]
list_per_page = 10000000
search_fields = ["first_name", "last_name", "wikidata"]
prepopulated_fields = {"slug": ("first_name", "last_name")}
"authors__gender", "authors__nationality",
"translators__gender", "translators__nationality",
"document_book__chunk__stage",
- #"document_book__chunk__user",
LicenseFilter,
CoverLicenseFilter,
+ 'free_license',
+ 'polona_missing',
]
list_per_page = 1000000
- readonly_fields = ["wikidata_link", "estimated_costs", "documents_book_link"]
- actions = [export_as_csv_action()]
+ readonly_fields = [
+ "wikidata_link",
+ "estimated_costs",
+ "documents_book_link",
+ "scans_source_link",
+ ]
+ actions = [export_as_csv_action(
+ fields=[
+ "id",
+ "wikidata",
+ "slug",
+ "title",
+ "authors_str", # authors?
+ "translators_str", # translators?
+ "language",
+ "based_on",
+ "scans_source",
+ "text_source",
+ "notes",
+ "priority",
+ "pd_year",
+ "gazeta_link",
+ "estimated_chars",
+ "estimated_verses",
+ "estimate_source"
+ ]
+ )]
fieldsets = [
(None, {"fields": [("wikidata", "wikidata_link")]}),
(
_("Plan"),
{
"fields": [
- "scans_source",
+ ("free_license", "polona_missing"),
+ ("scans_source", "scans_source_link"),
"text_source",
"priority",
"collections",
return mark_safe('<a style="position: absolute" href="{}"><img height="100" width="70" src="/cover/preview/{}/?height=100&width=70"></a>'.format(book.get_absolute_url(), book.slug))
documents_book_link.short_description = _('Book')
+ def scans_source_link(self, obj):
+ if obj.scans_source:
+ return format_html(
+ '<a href="{url}" target="_blank">{url}</a>',
+ url=obj.scans_source,
+ )
+ else:
+ return ""
+ scans_source_link.short_description = _('scans source')
+
admin.site.register(models.Book, BookAdmin)
--- /dev/null
+# Generated by Django 4.0.6 on 2022-09-19 12:22
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('catalogue', '0030_auto_20210706_1408'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='author',
+ name='place_of_birth',
+ field=models.CharField(blank=True, max_length=255, verbose_name='place of birth'),
+ ),
+ migrations.AddField(
+ model_name='author',
+ name='place_of_death',
+ field=models.CharField(blank=True, max_length=255, verbose_name='place of death'),
+ ),
+ migrations.AddField(
+ model_name='author',
+ name='year_of_birth',
+ field=models.SmallIntegerField(blank=True, null=True, verbose_name='year of birth'),
+ ),
+ ]
--- /dev/null
+# Generated by Django 4.0.6 on 2022-09-19 12:38
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('catalogue', '0031_author_place_of_birth_author_place_of_death_and_more'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='book',
+ name='free_license',
+ field=models.BooleanField(default=False, verbose_name='free license'),
+ ),
+ migrations.AddField(
+ model_name='book',
+ name='polona_missing',
+ field=models.BooleanField(default=False, verbose_name='missing on Polona'),
+ ),
+ ]
gender = models.CharField(_("gender"), max_length=255, blank=True)
nationality = models.CharField(_("nationality"), max_length=255, blank=True)
+ year_of_birth = models.SmallIntegerField(_("year of birth"), null=True, blank=True)
+ place_of_birth = models.CharField(_('place of birth'), max_length=255, blank=True)
year_of_death = models.SmallIntegerField(_("year of death"), null=True, blank=True)
+ place_of_death = models.CharField(_('place of death'), max_length=255, blank=True)
status = models.PositiveSmallIntegerField(
_("status"),
null=True,
notes = "description"
def __str__(self):
- return f"{self.first_name} {self.last_name}"
+ name = f"{self.first_name} {self.last_name}"
+ if self.year_of_death is not None:
+ name += f' (zm. {self.year_of_death})'
+ return name
def get_absolute_url(self):
return reverse("catalogue_author", args=[self.slug])
estimated_verses = models.IntegerField(_("estimated number of verses"), null=True, blank=True)
estimate_source = models.CharField(_("source of estimates"), max_length=2048, blank=True)
+ free_license = models.BooleanField(_('free license'), default=False)
+ polona_missing = models.BooleanField(_('missing on Polona'), default=False)
+
class Meta:
ordering = ("title",)
verbose_name = _('book')