From 6b985a0a184c49324857d01b2f22fd23ebd5f5a4 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 20 Apr 2020 17:12:25 +0200 Subject: [PATCH] Add wikidata links. --- src/catalogue/wikidata.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/catalogue/wikidata.py b/src/catalogue/wikidata.py index d97d3af7..4fc8bbd8 100644 --- a/src/catalogue/wikidata.py +++ b/src/catalogue/wikidata.py @@ -82,19 +82,19 @@ class WikidataMixin(models.Model): wdvalue = wdvalue.label.get("pl", str(wdvalue.label)) setattr(self, attname, wdvalue) - -class WikidataAdminMixin: - def save_related(self, request, form, formsets, change): - super().save_related(request, form, formsets, change) - form.instance.save() - - def wikidata_link(self, obj): - if obj.wikidata: + def wikidata_link(self): + if self.wikidata: return format_html( '{wd}', - wd=obj.wikidata, + wd=self.wikidata, ) else: return "" wikidata_link.admin_order_field = "wikidata" + + +class WikidataAdminMixin: + def save_related(self, request, form, formsets, change): + super().save_related(request, form, formsets, change) + form.instance.save() -- 2.20.1