Browse Source

Novinky | admin

Pridano lepsi zobrazeni v adminu.
Pridany akce na hromadne zverejnovani a zneverejnovani novinek.
remotes/origin/vysl
Bc. Petr Pecha 9 years ago
parent
commit
784a613784
  1. 17
      seminar/admin.py

17
seminar/admin.py

@ -360,8 +360,25 @@ class NovinkyAdminForm(forms.ModelForm):
model = Novinky model = Novinky
exclude = [] 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): class NovinkyAdmin(admin.ModelAdmin):
form = NovinkyAdminForm form = NovinkyAdminForm
list_display = ['datum', 'autor', 'text', 'zverejneno', 'obrazek']
actions = [zverejnit_novinky, zneverejnit_novinky]
admin.site.register(Novinky, NovinkyAdmin) admin.site.register(Novinky, NovinkyAdmin)

Loading…
Cancel
Save