From 784a613784c3ed3c67d37399a57737ea8acbff00 Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Thu, 10 Sep 2015 20:09:49 +0200 Subject: [PATCH] Novinky | admin Pridano lepsi zobrazeni v adminu. Pridany akce na hromadne zverejnovani a zneverejnovani novinek. --- seminar/admin.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/seminar/admin.py b/seminar/admin.py index 6c40bb8c..3a9fa74f 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -360,8 +360,25 @@ class NovinkyAdminForm(forms.ModelForm): model = Novinky exclude = [] +def zverejnit_novinky(modeladmin, request, queryset): + ''' zverejni vybrane novinky ''' + for novinka in queryset: + novinka.zverejneno = True + novinka.save() + zverejnit_novinky.short_description = 'Zveřejnit vybané novinky' + +def zneverejnit_novinky(modeladmin, request, queryset): + ''' zneverejni vybrane novinky''' + for novinka in queryset: + novinka.zverejneno = False + novinka.save() + zneverejnit_novinky.short_description = 'Zneveřejnit vybrané novinky' + + class NovinkyAdmin(admin.ModelAdmin): form = NovinkyAdminForm + list_display = ['datum', 'autor', 'text', 'zverejneno', 'obrazek'] + actions = [zverejnit_novinky, zneverejnit_novinky] admin.site.register(Novinky, NovinkyAdmin)