From dd01421b83db903b29668b593e841b78049fe668 Mon Sep 17 00:00:00 2001 From: Tomas 'Jethro' Pokorny Date: Tue, 23 Feb 2021 21:09:17 +0100 Subject: [PATCH] Admin | Bugfix search_fields, hezci admin problemu. --- seminar/admin.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/seminar/admin.py b/seminar/admin.py index 4ce6ded5..4da32e96 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -46,11 +46,11 @@ class OsobaAdmin(admin.ModelAdmin): @admin.register(m.Organizator) class OrganizatorAdmin(admin.ModelAdmin): - search_fields = ['osoba__jmeno', 'osoba__prijmeni', 'prezdivka'] + search_fields = ['osoba__jmeno', 'osoba__prijmeni', 'osoba__prezdivka'] @admin.register(m.Resitel) class ResitelAdmin(admin.ModelAdmin): - search_fields = ['jmeno', 'prijmeni', 'prezdivka'] + search_fields = ['osoba__jmeno', 'osoba__prijmeni', 'osoba__prezdivka'] ordering = ('osoba__jmeno','osoba__prijmeni') @admin.register(m.Problem) @@ -65,29 +65,28 @@ class ProblemAdmin(PolymorphicParentModelAdmin): # Pokud chceme orezavat na aktualni rocnik, musime do modelu pridat odkaz na rocnik. Zatim bere vse. search_fields = ['nazev'] +# V ProblemAdmin to nejde, protoze se to nepropise do deti +class ProblemAdminMixin(object): + show_in_index = True + autocomplete_fields = ['nadproblem','autor','garant'] + filter_horizontal = ['opravovatele'] + + @admin.register(m.Tema) -class TemaAdmin(PolymorphicChildModelAdmin): +class TemaAdmin(ProblemAdminMixin,PolymorphicChildModelAdmin): base_model = m.Tema - show_in_index = True - autocomplete_fields = ['nadproblem'] @admin.register(m.Clanek) -class ClanekAdmin(PolymorphicChildModelAdmin): +class ClanekAdmin(ProblemAdminMixin,PolymorphicChildModelAdmin): base_model = m.Clanek - show_in_index = True - autocomplete_fields = ['nadproblem'] @admin.register(m.Uloha) -class UlohaAdmin(PolymorphicChildModelAdmin): +class UlohaAdmin(ProblemAdminMixin,PolymorphicChildModelAdmin): base_model = m.Uloha - show_in_index = True - autocomplete_fields = ['nadproblem'] @admin.register(m.Konfera) -class KonferaAdmin(PolymorphicChildModelAdmin): +class KonferaAdmin(ProblemAdminMixin,PolymorphicChildModelAdmin): base_model = m.Konfera - show_in_index = True - autocomplete_fields = ['nadproblem'] class TextAdminInline(admin.TabularInline):