X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/2ad3a0ff948fcd754043b251e4767808babb25d2..9b533fdbfd08bd764744ae3a0d4717c87b61cf18:/src/catalogue/admin.py diff --git a/src/catalogue/admin.py b/src/catalogue/admin.py index 36d464c8..c319af50 100644 --- a/src/catalogue/admin.py +++ b/src/catalogue/admin.py @@ -240,6 +240,26 @@ class CoverLicenseFilter(LicenseFilter): license_name_field = 'document_book__dc_cover_image__license_name' +class ChildrenFilter(admin.SimpleListFilter): + title = 'Status utworu podrzędnego' + parameter_name = 'book_children' + + def lookups(self, requesrt, model_admin): + return [ + ('no', 'bez podrzędnych'), + ('only', 'tylko podrzędne'), + ] + + def queryset(self, request, queryset): + v = self.value() + if v == 'no': + return queryset.filter(parent=None) + elif v == 'only': + return queryset.exclude(parent=None) + else: + return queryset + + def add_title(base_class, suffix): class TitledCategoryFilter(base_class): def __init__(self, *args, **kwargs): @@ -308,8 +328,13 @@ class SourcesInline(admin.TabularInline): extra = 1 +class EditorNoteInline(admin.TabularInline): + model = models.EditorNote + extra = 1 + + class BookAdmin(WikidataAdminMixin, NumericFilterModelAdmin, VersionAdmin): - inlines = [SourcesInline] + inlines = [EditorNoteInline, SourcesInline] list_display = [ "smart_title", "authors_str", @@ -325,10 +350,11 @@ class BookAdmin(WikidataAdminMixin, NumericFilterModelAdmin, VersionAdmin): "translators__first_name", "translators__last_name", "scans_source", "text_source", "notes", "estimate_source", ] - autocomplete_fields = ["authors", "translators", "based_on", "epochs", "genres", "kinds"] + autocomplete_fields = ["parent", "authors", "translators", "based_on", "epochs", "genres", "kinds"] filter_horizontal = ['collections'] prepopulated_fields = {"slug": ("title",)} list_filter = [ + ChildrenFilter, "language", "based_on__language", ("pd_year", RangeNumericFilter), @@ -414,6 +440,7 @@ class BookAdmin(WikidataAdminMixin, NumericFilterModelAdmin, VersionAdmin): { "fields": [ "title", + ("parent", "parent_number"), ("slug", 'documents_book_link'), "authors", "translators", @@ -564,6 +591,16 @@ class GenreAdmin(CategoryAdmin): 'plural', 'is_epoch_specific', 'has_description', + 'thema', + ] + fields = [ + 'wikidata', + 'name', + 'plural', + 'slug', + 'is_epoch_specific', + 'thema', + 'description', ]