2015-10-11 22:13:12 +02:00
|
|
|
from galerie.models import Obrazek, Galerie
|
|
|
|
from django.contrib import admin
|
|
|
|
from django.http import HttpResponseRedirect
|
2015-12-04 20:09:42 +01:00
|
|
|
from django import forms
|
|
|
|
from django.db import models
|
2015-10-11 22:13:12 +02:00
|
|
|
|
2015-10-13 12:08:28 +02:00
|
|
|
# akction
|
|
|
|
|
|
|
|
def zverejnit_fotogalerii(modeladmin, request, queryset):
|
2019-05-11 01:15:05 +02:00
|
|
|
'''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'
|
2015-10-13 12:08:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
def prepnout_fotogalerii_do_org_rezimu(modeladmin, request, queryset):
|
2019-05-11 01:15:05 +02:00
|
|
|
'''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)'
|
2015-10-13 12:08:28 +02:00
|
|
|
|
2015-10-11 22:13:12 +02:00
|
|
|
class GalerieInline(admin.TabularInline):
|
2019-05-11 01:15:05 +02:00
|
|
|
model = Obrazek
|
2020-08-19 09:03:58 +02:00
|
|
|
fields = ['obrazek_velky', 'nazev', 'popis', 'obrazek_maly_tag', 'poradi']
|
2019-05-11 01:15:05 +02:00
|
|
|
readonly_fields = ['nazev', 'obrazek_maly_tag']
|
|
|
|
formfield_overrides = {
|
|
|
|
models.TextField: {'widget': forms.TextInput},
|
|
|
|
}
|
2015-10-11 22:13:12 +02:00
|
|
|
|
|
|
|
class ObrazekAdmin(admin.ModelAdmin):
|
2020-08-19 09:03:58 +02:00
|
|
|
list_display = ('obrazek_velky', 'nazev', 'popis', 'obrazek_maly_tag', 'poradi')
|
2019-08-31 22:16:16 +02:00
|
|
|
search_fields = ['nazev','popis']
|
2019-05-11 02:00:41 +02:00
|
|
|
|
2015-12-04 20:09:42 +01:00
|
|
|
class GalerieAdmin(admin.ModelAdmin):
|
2019-05-11 01:15:05 +02:00
|
|
|
model = Galerie
|
|
|
|
fields = ('zobrazit', 'nazev', 'titulni_obrazek', 'popis', 'galerie_up', 'soustredeni', 'poradi')
|
2019-08-31 22:16:16 +02:00
|
|
|
autocomplete_fields = ['titulni_obrazek']
|
2019-05-11 01:15:05 +02:00
|
|
|
list_display = ('nazev', 'soustredeni', 'galerie_up', 'poradi', 'zobrazit', 'datum_zmeny')
|
|
|
|
inlines = [GalerieInline]
|
|
|
|
actions = [zverejnit_fotogalerii, prepnout_fotogalerii_do_org_rezimu]
|
|
|
|
save_on_top = True
|
|
|
|
ordering = ['galerie_up__nazev', 'poradi']
|
2015-10-11 22:13:12 +02:00
|
|
|
|
|
|
|
admin.site.register(Obrazek, ObrazekAdmin)
|
|
|
|
admin.site.register(Galerie, GalerieAdmin)
|