From 81c561a1a86927d97c3caf461225852df098a023 Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Wed, 14 Aug 2019 01:34:50 +0200 Subject: [PATCH] =?UTF-8?q?Admin=20pro=20polymorfick=C3=A9=20probl=C3=A9my?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/admin.py | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/seminar/admin.py b/seminar/admin.py index 310df7fe..e524a19d 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -15,14 +15,32 @@ admin.site.register(m.Cislo) admin.site.register(m.Organizator) admin.site.register(m.Soustredeni) -# TODO: Polymorphic admin -admin.site.register(m.Problem) -admin.site.register(m.Tema) -admin.site.register(m.Clanek) -admin.site.register(m.Text) -admin.site.register(m.Uloha) -# END TODO. +@admin.register(m.Problem) +class ProblemAdmin(PolymorphicParentModelAdmin): + base_model = m.Problem + child_models = [ + m.Tema, + m.Clanek, + m.Uloha, + ] +@admin.register(m.Tema) +class TemaAdmin(PolymorphicChildModelAdmin): + base_model = m.Tema + show_in_index = True + +@admin.register(m.Clanek) +class ClanekAdmin(PolymorphicChildModelAdmin): + base_model = m.Clanek + show_in_index = True + +@admin.register(m.Uloha) +class UlohaAdmin(PolymorphicChildModelAdmin): + base_model = m.Uloha + show_in_index = True + + +admin.site.register(m.Text) admin.site.register(m.Reseni) admin.site.register(m.Hodnoceni) admin.site.register(m.PrilohaReseni)