|
|
@ -1,7 +1,31 @@ |
|
|
|
#coding: utf-8 |
|
|
|
|
|
|
|
from galerie.models import Obrazek, Galerie |
|
|
|
from django.contrib import admin |
|
|
|
from django.http import HttpResponseRedirect |
|
|
|
|
|
|
|
# akction |
|
|
|
|
|
|
|
def zverejnit_fotogalerii(modeladmin, request, queryset): |
|
|
|
'''zverejni vybranou fotogalerii i jeji vsechny podgalerie''' |
|
|
|
for galerie in queryset: |
|
|
|
galerie.zobrazit = 0 |
|
|
|
galerie.save() |
|
|
|
zverejnit_fotogalerii(modeladmin, request, |
|
|
|
Galerie.objects.filter(galerie_up = galerie)) |
|
|
|
zverejnit_fotogalerii.short_description = 'Zveřejnit fotogalerie' |
|
|
|
|
|
|
|
|
|
|
|
def prepnout_fotogalerii_do_org_rezimu(modeladmin, request, queryset): |
|
|
|
'''zneverjni vybranou fotogalerii i jeji vsechny podgalerie''' |
|
|
|
for galerie in queryset: |
|
|
|
galerie.zobrazit = 1 |
|
|
|
galerie.save() |
|
|
|
prepnout_fotogalerii_do_org_rezimu(modeladmin, request, |
|
|
|
Galerie.objects.filter(galerie_up = galerie)) |
|
|
|
prepnout_fotogalerii_do_org_rezimu.short_description = \ |
|
|
|
'Přepnout do režimu úprav (zneveřejní galerii)' |
|
|
|
|
|
|
|
class GalerieInline(admin.TabularInline): |
|
|
|
model = Obrazek |
|
|
|
|
|
|
@ -11,8 +35,9 @@ class ObrazekAdmin(admin.ModelAdmin): |
|
|
|
class GalerieAdmin(admin.ModelAdmin): |
|
|
|
model = Galerie |
|
|
|
fields = ('zobrazit', 'nazev', 'titulni_obrazek', 'popis', 'galerie_up', 'soustredeni') |
|
|
|
list_display = ('nazev', 'pk', 'datum_zmeny', 'zobrazit') |
|
|
|
list_display = ('nazev', 'pk', 'datum_zmeny', 'zobrazit', 'soustredeni') |
|
|
|
inlines = [GalerieInline] |
|
|
|
actions = [zverejnit_fotogalerii, prepnout_fotogalerii_do_org_rezimu] |
|
|
|
|
|
|
|
admin.site.register(Obrazek, ObrazekAdmin) |
|
|
|
admin.site.register(Galerie, GalerieAdmin) |
|
|
|