From b19cbe60325d254ff6307c8d0a4d15b6b216c4bd Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Sun, 5 Jul 2015 10:12:47 +0200 Subject: [PATCH] organizatori | admin | actions --- seminar/admin.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/seminar/admin.py b/seminar/admin.py index 8e6d8a96..6a491766 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -347,17 +347,35 @@ admin.site.register(Novinky, NovinkyAdmin) ### Organizator def jmeno_organizatora(obj): + ''' vraci jmeno organizatora ''' return ('%s \"%s\" %s' % (obj.user.first_name, obj.prezdivka, obj.user.last_name)) jmeno_organizatora.short_description = 'Jméno organizátora' def je_organizator_aktivni(obj): + ''' zjisti, zda-li je organizator aktivni ''' return obj.user.is_active je_organizator_aktivni.short_description = 'Aktivní' je_organizator_aktivni.boolean = True +def zaktivovat_organizatory(modeladmin, request, queryset): + ''' vybrane organizatory oznaci jako aktivni ''' + for org in queryset: + org.user.is_active = True + org.user.save() +zaktivovat_organizatory.short_description = 'Zaktivovat organizátory' + +def deaktivovat_organizatory(modeladmin, request, queryset): + ''' deaktivuje vybrane organizatory ''' + for org in queryset: + org.user.is_active = False + org.user.save() +deaktivovat_organizatory.short_description = 'Deaktivovat organizátory' + + @admin.register(Organizator) class OrganizatorAdmin(admin.ModelAdmin): list_filter = ['organizuje_do_roku'] list_display = [jmeno_organizatora, je_organizator_aktivni,] + actions = [zaktivovat_organizatory, deaktivovat_organizatory,]