X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/a7c64b2ae44b54daac2d4bce4dc0c2d675e04504..37f3ee92951cdf0d9742b37a5a5f839675b996ff:/src/catalogue/admin.py?ds=sidebyside diff --git a/src/catalogue/admin.py b/src/catalogue/admin.py index 43ae8664..7eafe7b3 100644 --- a/src/catalogue/admin.py +++ b/src/catalogue/admin.py @@ -15,6 +15,7 @@ from fnpdjango.actions import export_as_csv_action from modeltranslation.admin import TabbedTranslationAdmin from . import models import documents.models +import sources.models from .wikidata import WikidataAdminMixin @@ -73,6 +74,20 @@ class WoblinkCatalogueWidget(forms.Select): ) return attrs + def optgroups(self, name, value, attrs=None): + """ Add synthetic option for keeping the current value. """ + return [(None, [ + self.create_option( + name, + v, + '(bez zmian)', + selected=True, + index=index, + attrs=attrs, + ) + for index, v in enumerate(value) + ], 0)] + class WoblinkAuthorWidget(WoblinkCatalogueWidget): category = 'author' @@ -287,7 +302,13 @@ class FirstPublicationYearFilter(admin.ListFilter): ] +class SourcesInline(admin.TabularInline): + model = sources.models.BookSource + extra = 1 + + class BookAdmin(WikidataAdminMixin, NumericFilterModelAdmin): + inlines = [SourcesInline] list_display = [ "smart_title", "authors_str", @@ -399,6 +420,7 @@ class BookAdmin(WikidataAdminMixin, NumericFilterModelAdmin): "based_on", "original_year", "pd_year", + "plwiki", ] }, ),