Novinky | admin
Pridano lepsi zobrazeni v adminu. Pridany akce na hromadne zverejnovani a zneverejnovani novinek.
This commit is contained in:
parent
301e47c701
commit
784a613784
1 changed files with 17 additions and 0 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue