Web M&M
https://mam.matfyz.cz
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.9 KiB
53 lines
1.9 KiB
|
|
from galerie.models import Obrazek, Galerie
|
|
from django.contrib import admin
|
|
from django.http import HttpResponseRedirect
|
|
from django import forms
|
|
from django.db import models
|
|
|
|
# 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
|
|
fields = ['obrazek_velky', 'nazev', 'popis', 'obrazek_maly_tag', 'poradi']
|
|
readonly_fields = ['nazev', 'obrazek_maly_tag']
|
|
formfield_overrides = {
|
|
models.TextField: {'widget': forms.TextInput},
|
|
}
|
|
|
|
class ObrazekAdmin(admin.ModelAdmin):
|
|
list_display = ('obrazek_velky', 'nazev', 'popis', 'obrazek_maly_tag', 'poradi')
|
|
search_fields = ['nazev','popis']
|
|
|
|
class GalerieAdmin(admin.ModelAdmin):
|
|
model = Galerie
|
|
fields = ('zobrazit', 'nazev', 'titulni_obrazek', 'popis', 'galerie_up', 'soustredeni', 'poradi')
|
|
autocomplete_fields = ['titulni_obrazek']
|
|
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']
|
|
|
|
admin.site.register(Obrazek, ObrazekAdmin)
|
|
admin.site.register(Galerie, GalerieAdmin)
|
|
|