From 9460c484f72c98648e4a0f623c34a5fa74965c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Tue, 4 Feb 2025 23:09:47 +0100 Subject: [PATCH] =?UTF-8?q?Zobrazen=C3=AD=20Znalost=C3=AD=20(stejn=C4=9B?= =?UTF-8?q?=20jako=20P=C5=99edn=C3=A1=C5=A1ek)=20u=20dan=C3=A9ho=20seznamu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prednasky/admin.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/prednasky/admin.py b/prednasky/admin.py index 7ab77d24..07615f43 100644 --- a/prednasky/admin.py +++ b/prednasky/admin.py @@ -58,10 +58,40 @@ class Seznam_PrednaskaInline(admin.TabularInline): def has_add_permission(self, req, obj): return False +class Seznam_ZnalostInline(admin.TabularInline): + """ + Pomůcka pro :py:class:`prednasky.admin.SeznamAdmin` zobrazující hezky :py:class:`Znalosti ` + v adminu :py:class:`Seznamu `. + """ + model = Znalost.seznamy.through + extra = 0 + + def znalost__nazev(self, obj): + return mark_safe( + f"{obj.znalost.nazev}" + ) + + def znalost__text(self, obj): + return mark_safe( + f"
{escape(obj.znalost.text)}
" + ) + + znalost__nazev.short_description = u'Přednáška' + znalost__text.short_description = u'Popis pro orgy' + + readonly_fields = [ + 'znalost__nazev', + 'znalost__text', + ] + exclude = ['znalost'] + + def has_add_permission(self, req, obj): return False + + class SeznamAdmin(VersionAdmin): """ Admin pro :py:class:`Seznam ` """ list_display = ['soustredeni', 'stav'] - inlines = [Seznam_PrednaskaInline] + inlines = [Seznam_PrednaskaInline, Seznam_ZnalostInline] admin.site.register(Seznam, SeznamAdmin)