2014-11-17 12:05:46 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2015-07-23 21:32:44 +02:00
|
|
|
|
2014-11-17 12:05:46 +01:00
|
|
|
from django.contrib import admin
|
2015-03-14 22:27:04 +01:00
|
|
|
from django import forms
|
2015-05-22 00:10:07 +02:00
|
|
|
from django.forms import widgets
|
2015-10-25 13:17:49 +01:00
|
|
|
from reversion.admin import VersionAdmin
|
2015-03-14 15:41:29 +01:00
|
|
|
from solo.admin import SingletonModelAdmin
|
2018-09-14 22:24:52 +02:00
|
|
|
from ckeditor_uploader.widgets import CKEditorUploadingWidget
|
2015-05-21 22:30:35 +02:00
|
|
|
from django.db.models import Count
|
2015-05-22 00:10:07 +02:00
|
|
|
from django.db import models
|
2017-04-21 22:43:08 +02:00
|
|
|
from django.utils.safestring import mark_safe
|
|
|
|
from django.core.urlresolvers import reverse
|
2015-09-24 00:43:05 +02:00
|
|
|
|
2015-09-23 22:27:59 +02:00
|
|
|
from django.contrib.auth.models import User
|
2015-03-14 22:27:04 +01:00
|
|
|
|
2019-04-23 23:26:37 +02:00
|
|
|
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Soustredeni_Organizatori, Novinky, Organizator, Pohadka, Konfera, Uloha
|
2016-01-09 17:03:40 +01:00
|
|
|
from autocomplete_light import shortcuts as autocomplete_light
|
2015-05-21 17:44:51 +02:00
|
|
|
|
2015-09-23 22:27:59 +02:00
|
|
|
|
2015-09-24 00:43:05 +02:00
|
|
|
class UserModelChoiceField(forms.ModelChoiceField):
|
2015-09-24 11:11:54 +02:00
|
|
|
u"""Vlastní ModelChoiceField pro uživatele. Zobrazí kromě loginu i jméno.
|
|
|
|
"""
|
2015-09-24 00:43:05 +02:00
|
|
|
def label_from_instance(self, obj):
|
|
|
|
return u"{} ({})".format(obj.get_full_name(), obj.username)
|
2015-05-21 17:44:51 +02:00
|
|
|
|
2015-09-24 11:11:54 +02:00
|
|
|
def get_form_predvypln_autora(self, request, obj=None, *args, **kwargs):
|
|
|
|
u"""get_form fce pro Adminy. Předvyplňí přihlášeného uživatele jako autora.
|
2015-09-23 20:38:10 +02:00
|
|
|
"""
|
2015-09-24 11:11:54 +02:00
|
|
|
form = super(self.__class__, self).get_form(request, *args, **kwargs)
|
|
|
|
form.base_fields['autor'].initial = request.user.id
|
|
|
|
return form
|
2015-09-23 20:38:10 +02:00
|
|
|
|
|
|
|
|
2015-07-23 21:32:44 +02:00
|
|
|
def make_set_action(atribut, hodnota, nazev):
|
|
|
|
u"""
|
|
|
|
Pomocnik pro rychle vytvareni hromadnych admin akci ktere jen nastavuji
|
|
|
|
atribut (dany jako string) na danou hodnotu.
|
|
|
|
nazev je krátký popis akce pro admin rozhraní."""
|
|
|
|
def action_f(modeladmin, request, queryset):
|
|
|
|
for obj in queryset:
|
|
|
|
assert atribut in obj.__dict__
|
|
|
|
obj.__setattr__(atribut, hodnota)
|
|
|
|
obj.save()
|
|
|
|
action_f.short_description = nazev
|
|
|
|
# Trik: je potřeba, aby se funkce různě (ale libovolně) jmenovaly,
|
|
|
|
# jinak je Django v seznamu akcí splácne do jedné
|
|
|
|
action_f.__name__ = 'action_f_%d_%d_%d' % (id(atribut), id(hodnota), id(nazev), )
|
|
|
|
return action_f
|
|
|
|
|
|
|
|
|
2015-05-21 17:44:51 +02:00
|
|
|
### Globální nastavení
|
2015-03-14 15:41:29 +01:00
|
|
|
|
|
|
|
admin.site.register(Nastaveni, SingletonModelAdmin)
|
2014-11-17 12:05:46 +01:00
|
|
|
|
2015-03-13 20:08:18 +01:00
|
|
|
|
2015-05-26 23:49:17 +02:00
|
|
|
### UTILS (pro verbose_name a help_text)
|
|
|
|
|
|
|
|
def field_labels(model, fieldname):
|
|
|
|
f = [i for i in model._meta.fields if i.name == fieldname][0]
|
|
|
|
return {'label': f.verbose_name.capitalize(), 'help_text': f.help_text, }
|
|
|
|
|
2015-05-27 09:20:15 +02:00
|
|
|
def create_modeladmin(modeladmin, model, name = None, verbose_name = None, verbose_name_plural = None):
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
proxy = True
|
|
|
|
app_label = model._meta.app_label
|
|
|
|
Meta.verbose_name = verbose_name
|
|
|
|
Meta.verbose_name_plural = verbose_name_plural
|
|
|
|
|
|
|
|
attrs = {'__module__': '', 'Meta': Meta}
|
|
|
|
newmodel = type(name, (model,), attrs)
|
|
|
|
admin.site.register(newmodel, modeladmin)
|
|
|
|
return modeladmin
|
|
|
|
|
2015-05-21 17:44:51 +02:00
|
|
|
### INLINES
|
2014-11-17 12:05:46 +01:00
|
|
|
|
2015-05-21 17:44:51 +02:00
|
|
|
class ResitelInline(admin.TabularInline):
|
|
|
|
model = Resitel
|
2019-04-30 21:48:46 +02:00
|
|
|
fields = ['osoba_jmeno', 'osoba_prijmeni', 'skola', 'osoba_mesto', 'rok_maturity', ]
|
|
|
|
readonly_fields = ['osoba_jmeno', 'osoba_prijmeni', 'skola', 'osoba_mesto', 'rok_maturity', ]
|
2015-05-21 17:44:51 +02:00
|
|
|
extra = 0
|
2016-08-06 17:03:21 +02:00
|
|
|
view_on_site = False
|
2015-05-21 22:18:44 +02:00
|
|
|
|
2019-04-30 21:48:46 +02:00
|
|
|
def osoba_jmeno(self, obj):
|
|
|
|
return obj.osoba.jmeno
|
|
|
|
|
|
|
|
def osoba_prijmeni(self, obj):
|
|
|
|
return obj.osoba.prijmeni
|
|
|
|
|
|
|
|
def osoba_mesto(self, obj):
|
|
|
|
return obj.osoba.mesto
|
|
|
|
|
2015-05-21 17:44:51 +02:00
|
|
|
def has_add_permission(self, req): return False
|
2014-11-17 12:05:46 +01:00
|
|
|
|
|
|
|
|
2015-05-21 17:44:51 +02:00
|
|
|
class CisloInline(admin.TabularInline):
|
|
|
|
model = Cislo
|
2017-01-20 22:58:13 +01:00
|
|
|
fields = ['cislo',
|
|
|
|
'datum_vydani', 'datum_deadline', 'datum_deadline_soustredeni',
|
2017-01-20 22:44:20 +01:00
|
|
|
'verejne_db', 'poznamka']
|
2015-05-21 17:44:51 +02:00
|
|
|
readonly_fields = ['cislo']
|
|
|
|
extra = 0
|
2015-05-22 00:10:07 +02:00
|
|
|
formfield_overrides = {
|
|
|
|
models.TextField: {'widget': forms.TextInput},
|
|
|
|
}
|
2016-08-06 17:03:21 +02:00
|
|
|
view_on_site = Cislo.verejne_url
|
2015-05-21 22:18:44 +02:00
|
|
|
|
2015-05-21 17:44:51 +02:00
|
|
|
def has_add_permission(self, req): return False
|
|
|
|
|
|
|
|
|
|
|
|
class PrilohaReseniInline(admin.StackedInline):
|
|
|
|
model = PrilohaReseni
|
2019-04-30 21:12:32 +02:00
|
|
|
fields = ['vytvoreno', 'soubor', 'poznamka']
|
|
|
|
readonly_fields = ['vytvoreno']
|
2015-05-22 00:10:07 +02:00
|
|
|
formfield_overrides = {
|
|
|
|
models.TextField: {'widget': forms.TextInput},
|
|
|
|
}
|
2016-08-06 17:03:21 +02:00
|
|
|
view_on_site = False
|
2015-05-21 22:18:44 +02:00
|
|
|
|
2015-05-21 17:44:51 +02:00
|
|
|
extra = 0
|
|
|
|
|
2016-08-06 17:03:21 +02:00
|
|
|
|
2016-08-06 17:06:12 +02:00
|
|
|
class ProblemInline(admin.TabularInline):
|
|
|
|
model = Problem
|
2019-04-30 21:39:22 +02:00
|
|
|
fields = ['kod', 'nazev', 'autor', 'garant', 'opravovatele', 'stav']
|
2016-08-06 17:06:12 +02:00
|
|
|
formfield_overrides = {
|
|
|
|
models.TextField: {'widget': forms.TextInput},
|
|
|
|
}
|
|
|
|
view_on_site = Problem.verejne_url
|
|
|
|
|
|
|
|
extra = 0
|
|
|
|
|
|
|
|
|
2015-05-21 17:44:51 +02:00
|
|
|
class ReseniKProblemuInline(admin.TabularInline):
|
2019-04-23 23:26:37 +02:00
|
|
|
form = autocomplete_light.modelform_factory(Reseni, autocomplete_fields=['resitele'], fields=['resitele'])
|
2015-05-21 17:44:51 +02:00
|
|
|
model = Reseni
|
2019-04-23 23:26:37 +02:00
|
|
|
fields = ['resitele', 'forma', 'body', 'cislo_body', 'timestamp', 'poznamka']
|
2015-05-21 17:44:51 +02:00
|
|
|
readonly_fields = ['timestamp']
|
|
|
|
extra = 0
|
2015-05-22 00:10:07 +02:00
|
|
|
formfield_overrides = {
|
|
|
|
models.TextField: {'widget': forms.TextInput},
|
|
|
|
}
|
2016-08-06 17:03:21 +02:00
|
|
|
view_on_site = False
|
2015-05-21 17:44:51 +02:00
|
|
|
|
2015-05-21 22:18:44 +02:00
|
|
|
def get_queryset(self, request):
|
|
|
|
qs = super(ReseniKProblemuInline, self).get_queryset(request)
|
2019-04-23 23:26:37 +02:00
|
|
|
return qs.select_related('problem', 'cislo_body', 'resitele')
|
2015-05-21 22:18:44 +02:00
|
|
|
|
|
|
|
# Potenciální DB HOG (cislo_body se dotazovalo na cisla pri kazdem zobrazeni jejich selectu ...)
|
|
|
|
def formfield_for_dbfield(self, db_field, **kwargs):
|
|
|
|
formfield = super(ReseniKProblemuInline, self).formfield_for_dbfield(db_field, **kwargs)
|
|
|
|
if db_field.name == 'cislo_body':
|
|
|
|
# dirty trick so queryset is evaluated and cached in .choices
|
|
|
|
formfield.choices = formfield.choices
|
|
|
|
return formfield
|
|
|
|
|
2015-05-21 17:44:51 +02:00
|
|
|
|
|
|
|
class ReseniKResiteliInline(admin.TabularInline):
|
|
|
|
model = Reseni
|
|
|
|
fields = ['problem', 'forma', 'body', 'cislo_body', 'timestamp', 'poznamka']
|
2019-04-30 21:39:22 +02:00
|
|
|
readonly_fields = ['cas_doruceni', 'problem']
|
2015-05-21 17:44:51 +02:00
|
|
|
extra = 0
|
2015-05-22 00:10:07 +02:00
|
|
|
formfield_overrides = {
|
|
|
|
models.TextField: {'widget': forms.TextInput},
|
|
|
|
}
|
2016-08-06 17:03:21 +02:00
|
|
|
view_on_site = False
|
2015-05-21 22:18:44 +02:00
|
|
|
|
2015-05-21 17:44:51 +02:00
|
|
|
def has_add_permission(self, req): return False
|
2014-11-17 12:05:46 +01:00
|
|
|
|
2015-05-21 22:18:44 +02:00
|
|
|
def get_queryset(self, request):
|
|
|
|
qs = super(ReseniKResiteliInline, self).get_queryset(request)
|
|
|
|
return qs.select_related('problem', 'cislo_body', 'resitel')
|
|
|
|
|
|
|
|
# Potenciální DB HOG (cislo_body se dotazovalo na cisla pri kazdem zobrazeni jejich selectu ...)
|
|
|
|
def formfield_for_dbfield(self, db_field, **kwargs):
|
|
|
|
formfield = super(ReseniKResiteliInline, self).formfield_for_dbfield(db_field, **kwargs)
|
|
|
|
if db_field.name == 'cislo_body':
|
|
|
|
# dirty trick so queryset is evaluated and cached in .choices
|
|
|
|
formfield.choices = formfield.choices
|
|
|
|
return formfield
|
|
|
|
|
2015-05-21 17:44:51 +02:00
|
|
|
|
|
|
|
class Soustredeni_UcastniciInline(admin.TabularInline):
|
|
|
|
form = autocomplete_light.modelform_factory(Soustredeni_Ucastnici, autocomplete_fields=['resitel'], fields=['resitel'])
|
|
|
|
model = Soustredeni_Ucastnici
|
|
|
|
fields = ['resitel', 'poznamka', ]
|
|
|
|
extra = 0
|
2015-05-22 00:10:07 +02:00
|
|
|
formfield_overrides = {
|
|
|
|
models.TextField: {'widget': forms.TextInput},
|
|
|
|
}
|
2014-11-17 12:05:46 +01:00
|
|
|
|
2015-05-21 22:58:37 +02:00
|
|
|
def get_queryset(self, request):
|
|
|
|
qs = super(Soustredeni_UcastniciInline, self).get_queryset(request)
|
|
|
|
return qs.select_related('resitel', 'soustredeni')
|
2014-11-17 12:05:46 +01:00
|
|
|
|
2016-10-05 08:55:28 +02:00
|
|
|
|
2015-12-22 15:22:40 +01:00
|
|
|
class Soustredeni_OrganizatoriInline(admin.TabularInline):
|
|
|
|
form = autocomplete_light.modelform_factory(Soustredeni_Organizatori, autocomplete_fields=['organizator'], fields=['organizator'],)
|
|
|
|
model = Soustredeni_Organizatori
|
|
|
|
fields = ['organizator', 'poznamka', ]
|
|
|
|
extra = 0
|
|
|
|
formfield_overrides = {
|
|
|
|
models.TextField: {'widget': forms.TextInput},
|
|
|
|
}
|
|
|
|
|
|
|
|
def get_queryset(self, request):
|
|
|
|
qs = super(Soustredeni_OrganizatoriInline, self).get_queryset(request)
|
|
|
|
return qs.select_related('organizator', 'soustredeni')
|
|
|
|
|
2015-03-13 20:08:18 +01:00
|
|
|
### Resitel
|
|
|
|
|
2015-10-25 13:17:49 +01:00
|
|
|
class ResitelAdmin(VersionAdmin):
|
2015-05-17 14:39:57 +02:00
|
|
|
form = autocomplete_light.modelform_factory(Resitel, autocomplete_fields=['skola'], fields=['skola'])
|
2019-04-30 22:08:54 +02:00
|
|
|
fk_name = 'osoba'
|
2014-11-17 12:05:46 +01:00
|
|
|
fieldsets = [
|
|
|
|
(None, {'fields': ['jmeno', 'prijmeni', 'user']}),
|
|
|
|
(u'Škola', {'fields': ['skola', 'rok_maturity']}),
|
|
|
|
(u'Seminář', {'fields': ['datum_souhlasu_udaje', 'datum_souhlasu_zasilani', 'datum_prihlaseni', 'zasilat']}),
|
|
|
|
(u'Osobní údaje', {'fields': ['pohlavi_muz', 'datum_narozeni', 'email', 'telefon']}),
|
|
|
|
(u'Adresa', {'fields': ['ulice', 'mesto', 'psc', 'stat']}),
|
|
|
|
]
|
2019-04-30 22:08:54 +02:00
|
|
|
list_display = ['osoba__jmeno', 'osoba__prijmeni', 'osoba__user', 'osoba__pohlavi_muz', 'skola', 'rok_maturity', 'pocet_reseni']
|
|
|
|
list_filter = ['osoba__pohlavi_muz', 'rok_maturity', 'zasilat']
|
|
|
|
search_fields = ['osoba__jmeno', 'osoba__prijmeni', 'osoba__ulice', 'osoba__mesto', 'osoba__email']
|
2019-04-30 22:09:46 +02:00
|
|
|
# inlines = [ReseniKResiteliInline] # FIXME:
|
2016-08-06 17:03:21 +02:00
|
|
|
view_on_site = False
|
2014-11-17 12:05:46 +01:00
|
|
|
|
2019-04-30 22:08:54 +02:00
|
|
|
def osoba__jmeno(self, obj):
|
|
|
|
return obj.osoba.jmeno
|
|
|
|
|
|
|
|
def osoba__prijmeni(self, obj):
|
|
|
|
return obj.osoba.prijmeni
|
|
|
|
|
|
|
|
def osoba__user(self, obj):
|
|
|
|
return obj.osoba.user
|
|
|
|
|
|
|
|
def osoba__pohlavi_muz(self, obj):
|
|
|
|
return obj.osoba.pohlavi_muz
|
|
|
|
|
|
|
|
def osoba__ulice(self, obj):
|
|
|
|
return obj.osoba.ulice
|
|
|
|
|
|
|
|
def osoba__mesto(self, obj):
|
|
|
|
return obj.osoba.mesto
|
|
|
|
|
|
|
|
def osoba__email(self, obj):
|
|
|
|
return obj.osoba.email
|
|
|
|
|
2015-05-21 22:18:44 +02:00
|
|
|
def get_queryset(self, request):
|
|
|
|
qs = super(ResitelAdmin, self).get_queryset(request)
|
2015-05-21 22:30:35 +02:00
|
|
|
return qs.select_related('skola', 'user').annotate(pocet_reseni=Count('reseni'))
|
|
|
|
|
|
|
|
def pocet_reseni(self, obj):
|
|
|
|
return obj.pocet_reseni
|
|
|
|
|
2014-11-17 12:05:46 +01:00
|
|
|
|
|
|
|
admin.site.register(Resitel, ResitelAdmin)
|
2015-03-13 20:08:18 +01:00
|
|
|
|
|
|
|
|
2015-05-21 17:44:51 +02:00
|
|
|
### Skola
|
|
|
|
|
2015-10-25 13:17:49 +01:00
|
|
|
class SkolaAdmin(VersionAdmin):
|
2015-05-21 17:44:51 +02:00
|
|
|
fieldsets = [
|
|
|
|
(None, {'fields': ['nazev', 'kratky_nazev', 'je_zs', 'je_ss']}),
|
|
|
|
(u'Interní ID', {'fields': ['aesop_id', 'izo'], 'classes': ['collapse']}),
|
|
|
|
(u'Adresa', {'fields': ['ulice', 'mesto', 'psc', 'stat']}),
|
|
|
|
(None, {'fields': ['poznamka']}),
|
|
|
|
]
|
|
|
|
list_display = ['nazev', 'aesop_id', 'mesto', 'ulice', 'stat', 'je_zs', 'je_ss']
|
|
|
|
list_filter = ['stat', 'je_zs', 'je_ss']
|
|
|
|
search_fields = ['nazev', 'mesto', 'ulice']
|
|
|
|
inlines = [ResitelInline]
|
2016-08-06 17:03:21 +02:00
|
|
|
view_on_site = False
|
2015-05-21 17:44:51 +02:00
|
|
|
|
|
|
|
admin.site.register(Skola, SkolaAdmin)
|
|
|
|
|
|
|
|
|
2015-03-13 20:08:18 +01:00
|
|
|
### Cislo
|
|
|
|
|
2015-10-25 13:17:49 +01:00
|
|
|
class CisloAdmin(VersionAdmin):
|
2015-03-13 20:08:18 +01:00
|
|
|
fieldsets = [
|
2016-11-06 21:20:10 +01:00
|
|
|
(None, {
|
|
|
|
'fields': [
|
|
|
|
'cislo',
|
|
|
|
'rocnik',
|
|
|
|
'verejne_db',
|
|
|
|
'verejna_vysledkovka',
|
|
|
|
'faze',
|
|
|
|
'poznamka',
|
|
|
|
'pdf'
|
|
|
|
]
|
|
|
|
}),
|
2019-04-30 21:39:22 +02:00
|
|
|
('Data', {'fields': ['datum_vydani', 'datum_deadline',
|
2017-01-20 22:58:13 +01:00
|
|
|
'datum_deadline_soustredeni']}),
|
2015-03-13 20:08:18 +01:00
|
|
|
]
|
2016-11-06 21:20:10 +01:00
|
|
|
list_display = [
|
|
|
|
'kod',
|
|
|
|
'rocnik',
|
|
|
|
'cislo',
|
|
|
|
'datum_vydani',
|
|
|
|
'datum_deadline',
|
|
|
|
'verejne',
|
|
|
|
'verejna_vysledkovka'
|
|
|
|
]
|
2015-03-13 20:08:18 +01:00
|
|
|
list_filter = ['rocnik']
|
2015-05-14 16:57:12 +02:00
|
|
|
view_on_site = Cislo.verejne_url
|
2015-07-23 21:57:23 +02:00
|
|
|
actions = [
|
2019-04-30 21:39:22 +02:00
|
|
|
make_set_action('verejne_db', True, 'Zveřejnit číslo'),
|
|
|
|
make_set_action('verejne_db', False, 'Skrýt (zneveřejnit) číslo'),
|
|
|
|
make_set_action('verejna_vysledkovka', True, 'Zveřejnit výsledkovku'),
|
|
|
|
make_set_action('verejna_vysledkovka', False, 'Skrýt (zneveřejnit) výsledkovku'),
|
2015-07-23 21:57:23 +02:00
|
|
|
]
|
2019-04-30 22:13:43 +02:00
|
|
|
#inlines = [ProblemInline]
|
2015-07-23 21:57:23 +02:00
|
|
|
|
2015-05-21 22:18:44 +02:00
|
|
|
def get_queryset(self, request):
|
|
|
|
qs = super(CisloAdmin, self).get_queryset(request)
|
|
|
|
return qs.select_related('rocnik')
|
2015-03-13 20:08:18 +01:00
|
|
|
|
|
|
|
admin.site.register(Cislo, CisloAdmin)
|
|
|
|
|
|
|
|
### Rocnik
|
|
|
|
|
2015-10-25 13:17:49 +01:00
|
|
|
class RocnikAdmin(VersionAdmin):
|
2015-03-13 20:08:18 +01:00
|
|
|
fieldsets = [
|
2015-07-23 20:42:50 +02:00
|
|
|
(None, {'fields': ['rocnik', 'prvni_rok', 'exportovat']}),
|
2015-03-13 20:08:18 +01:00
|
|
|
]
|
2015-07-23 20:42:50 +02:00
|
|
|
list_display = ['rocnik', 'prvni_rok', 'exportovat', 'verejne']
|
2015-03-13 20:08:18 +01:00
|
|
|
inlines = [CisloInline]
|
2015-05-14 16:57:12 +02:00
|
|
|
view_on_site = Rocnik.verejne_url
|
2015-07-23 21:57:23 +02:00
|
|
|
actions = [
|
|
|
|
make_set_action('exportovat', True, u'Nastavit pro AESOP export'),
|
|
|
|
make_set_action('exportovat', False, u'Skrýt pro AESOP export'),
|
|
|
|
]
|
2015-03-13 20:08:18 +01:00
|
|
|
|
|
|
|
admin.site.register(Rocnik, RocnikAdmin)
|
|
|
|
|
|
|
|
|
|
|
|
### PrilohaReseni
|
2015-05-21 17:44:51 +02:00
|
|
|
# NOTE: Nemá pravděpodobně smysl používat
|
|
|
|
# class PrilohaReseniAdmin(reversion.VersionAdmin):
|
|
|
|
# readonly_fields = ['timestamp', 'reseni']
|
|
|
|
# fieldsets = [
|
|
|
|
# (None, {'fields': ['reseni', 'soubor', 'timestamp']}),
|
|
|
|
# (u'Poznámky', {'fields': ['poznamka']}),
|
|
|
|
# ]
|
|
|
|
# list_display = ['reseni', 'soubor', 'timestamp']
|
|
|
|
# list_filter = ['reseni', 'timestamp']
|
|
|
|
# search_fields = []
|
|
|
|
#
|
|
|
|
# admin.site.register(PrilohaReseni, PrilohaReseniAdmin)
|
2015-03-13 20:08:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
### Reseni
|
|
|
|
|
2015-10-25 13:17:49 +01:00
|
|
|
class ReseniAdmin(VersionAdmin):
|
2019-04-23 23:26:37 +02:00
|
|
|
#form = autocomplete_light.modelform_factory(Reseni, autocomplete_fields=['problem', 'resitele'], fields=['problem', 'resitele'])
|
2015-03-13 20:08:18 +01:00
|
|
|
fieldsets = [
|
2019-04-30 21:46:57 +02:00
|
|
|
(None, {'fields': ['problem__set', 'resitele__set', 'forma', 'cas_doruceni']}),
|
2015-05-14 16:18:43 +02:00
|
|
|
(u'Poznámky', {'fields': ['poznamka']}),
|
2015-03-13 20:08:18 +01:00
|
|
|
]
|
2019-04-30 21:46:57 +02:00
|
|
|
readonly_fields = ['cas_doruceni']
|
2019-04-30 22:13:43 +02:00
|
|
|
list_display = [ResitelInline, 'forma', 'cas_doruceni']
|
2019-04-30 21:46:57 +02:00
|
|
|
list_filter = ['cas_doruceni', 'forma']
|
2015-03-13 20:08:18 +01:00
|
|
|
search_fields = []
|
2019-04-30 22:14:54 +02:00
|
|
|
inlines = [PrilohaReseniInline] # FIXME: odmazáno ProblemInline,ResitelInline
|
2016-08-06 17:03:21 +02:00
|
|
|
view_on_site = False
|
2015-03-13 20:08:18 +01:00
|
|
|
|
2015-05-21 22:18:44 +02:00
|
|
|
def get_queryset(self, request):
|
|
|
|
qs = super(ReseniAdmin, self).get_queryset(request)
|
2019-04-23 23:26:37 +02:00
|
|
|
return qs.select_related('resitele', 'problem', 'cislo_body')
|
2015-03-13 20:08:18 +01:00
|
|
|
|
|
|
|
admin.site.register(Reseni, ReseniAdmin)
|
|
|
|
|
|
|
|
|
2016-02-16 00:04:26 +01:00
|
|
|
### Pohádka
|
|
|
|
|
|
|
|
class PohadkaAdminForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Pohadka
|
|
|
|
exclude = []
|
|
|
|
autor = UserModelChoiceField(User.objects.filter(is_staff=True))
|
2017-04-09 21:59:36 +02:00
|
|
|
uloha = forms.ModelChoiceField(
|
2019-04-23 23:26:37 +02:00
|
|
|
Uloha.objects.all()
|
2017-04-09 21:59:36 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(PohadkaAdminForm, self).__init__(*args, **kwargs)
|
|
|
|
instance = getattr(self, 'instance', None)
|
|
|
|
|
|
|
|
# viz ProblemAdminForm.__init__
|
|
|
|
if instance and instance.pk:
|
|
|
|
if instance.uloha and instance.uloha.cislo_zadani:
|
|
|
|
if instance.uloha.cislo_zadani.faze != 'admin':
|
|
|
|
self.fields['text'].widget.attrs['readonly'] = True
|
|
|
|
|
2016-02-16 00:04:26 +01:00
|
|
|
|
|
|
|
class PohadkaAdmin(VersionAdmin):
|
|
|
|
form = PohadkaAdminForm
|
2016-08-06 17:03:21 +02:00
|
|
|
view_on_site = False
|
2016-02-16 00:04:26 +01:00
|
|
|
|
|
|
|
def get_kod_ulohy(self, obj):
|
|
|
|
return obj.uloha.kod_v_rocniku()
|
|
|
|
get_kod_ulohy.short_description = u'Kód úlohy'
|
|
|
|
|
|
|
|
def get_rocnik(self, obj):
|
|
|
|
return obj.uloha.cislo_zadani.rocnik.rocnik
|
|
|
|
get_rocnik.short_description = u'Ročník'
|
|
|
|
|
2016-11-06 21:20:10 +01:00
|
|
|
list_display = [
|
|
|
|
'__str__',
|
|
|
|
'get_rocnik',
|
|
|
|
'get_kod_ulohy',
|
|
|
|
'uloha',
|
2019-04-30 21:12:32 +02:00
|
|
|
'autor'
|
2016-11-06 21:20:10 +01:00
|
|
|
]
|
2016-02-16 00:04:26 +01:00
|
|
|
|
|
|
|
get_form = get_form_predvypln_autora
|
|
|
|
|
|
|
|
class PohadkaKProblemuInline(admin.TabularInline):
|
|
|
|
form = PohadkaAdminForm
|
|
|
|
model = Pohadka
|
|
|
|
exclude = []
|
|
|
|
extra = 0
|
|
|
|
|
|
|
|
admin.site.register(Pohadka, PohadkaAdmin)
|
|
|
|
|
|
|
|
|
2015-03-13 20:08:18 +01:00
|
|
|
### Problem
|
|
|
|
|
2015-05-21 22:18:44 +02:00
|
|
|
from autocomplete_light.contrib.taggit_field import TaggitField, TaggitWidget
|
|
|
|
|
2015-05-27 09:20:15 +02:00
|
|
|
|
2015-03-14 22:27:04 +01:00
|
|
|
class ProblemAdminForm(forms.ModelForm):
|
2019-04-23 23:26:37 +02:00
|
|
|
#text_zadani = forms.CharField(widget=CKEditorUploadingWidget(), required=False, **field_labels(Problem, 'text_zadani'))
|
|
|
|
#text_reseni = forms.CharField(widget=CKEditorUploadingWidget(), required=False, **field_labels(Problem, 'text_reseni'))
|
|
|
|
#text_org = forms.CharField(widget=CKEditorUploadingWidget(), required=False, **field_labels(Problem, 'text_org'))
|
2015-06-02 01:43:50 +02:00
|
|
|
zamereni = TaggitField(widget=TaggitWidget('TagAutocomplete'), required=False)
|
2015-09-24 00:43:05 +02:00
|
|
|
autor = UserModelChoiceField(User.objects.filter(is_staff=True))
|
2015-09-24 11:11:54 +02:00
|
|
|
opravovatel = UserModelChoiceField(User.objects.filter(is_staff=True), required=False)
|
2015-03-14 22:27:04 +01:00
|
|
|
class Meta:
|
|
|
|
model = Problem
|
2019-04-23 23:26:37 +02:00
|
|
|
exclude = ['nadproblem']
|
2015-03-14 22:27:04 +01:00
|
|
|
|
2017-04-09 21:59:36 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(ProblemAdminForm, self).__init__(*args, **kwargs)
|
|
|
|
instance = getattr(self, 'instance', None)
|
|
|
|
|
|
|
|
# Nedovol měnit název a zadání resp. řešení, pokud je cislo_zadani
|
|
|
|
# resp. cislo_reseni mimo fázi admin.
|
|
|
|
#
|
|
|
|
# Nastavení readonly fields sice vypadá lépe (nevygeneruje input tag),
|
|
|
|
# ale při ukládání změny vypíše admin nespecifikovanou chybu, která je
|
|
|
|
# způsobena zřejmě tím, že se neodešle žádná hodnota pro povinné pole
|
|
|
|
# nazev. Navíc by se smazalo nepovinné pole zadání.
|
|
|
|
#
|
|
|
|
# Toto řešení je z http://stackoverflow.com/a/325038/4786205.
|
|
|
|
#
|
|
|
|
# TODO Django 1.9: použít field s atributem disabled?
|
|
|
|
if instance and instance.pk:
|
|
|
|
if instance.cislo_zadani and instance.cislo_zadani.faze != 'admin':
|
|
|
|
# CKEditor neumí readonly ...
|
|
|
|
self.fields['text_zadani'] = forms.CharField(
|
|
|
|
widget=forms.Textarea,
|
|
|
|
required=False
|
|
|
|
)
|
|
|
|
for f in ['nazev', 'text_zadani', 'body']:
|
|
|
|
self.fields[f].widget.attrs['readonly'] = True
|
|
|
|
if instance.cislo_reseni and instance.cislo_reseni.faze != 'admin':
|
|
|
|
self.fields['text_reseni'] = forms.CharField(
|
|
|
|
widget=forms.Textarea,
|
|
|
|
required=False
|
|
|
|
)
|
|
|
|
self.fields['text_reseni'].widget.attrs['readonly'] = True
|
|
|
|
|
|
|
|
|
2015-10-25 13:17:49 +01:00
|
|
|
class ProblemAdmin(VersionAdmin):
|
2015-03-14 22:27:04 +01:00
|
|
|
form = ProblemAdminForm
|
2015-03-13 20:08:18 +01:00
|
|
|
fieldsets = [
|
2015-05-26 13:12:56 +02:00
|
|
|
(None, {'fields': ['nazev', 'typ', 'stav', 'autor', 'zamereni', 'body', 'timestamp', 'import_dakos_id']}),
|
2019-04-30 21:39:22 +02:00
|
|
|
(u'Vydání', {'fields': ['kod', 'cislo_reseni', 'opravovatel',]}),
|
2015-05-26 23:37:54 +02:00
|
|
|
(None, {'fields': ['text_zadani', 'text_reseni', 'text_org',]}),
|
2015-03-13 20:08:18 +01:00
|
|
|
]
|
2015-05-14 16:57:12 +02:00
|
|
|
list_select_related = True
|
2015-05-27 09:20:15 +02:00
|
|
|
search_fields = ['nazev', 'text_zadani', 'text_reseni', 'text_org']
|
2015-05-14 16:57:12 +02:00
|
|
|
view_on_site = Problem.verejne_url
|
2015-11-09 19:45:50 +01:00
|
|
|
ordering = ['-timestamp']
|
2015-03-13 20:08:18 +01:00
|
|
|
|
2017-04-09 21:59:36 +02:00
|
|
|
readonly_fields = ['timestamp', 'import_dakos_id']
|
2016-11-06 21:20:10 +01:00
|
|
|
|
2015-05-21 22:18:44 +02:00
|
|
|
def get_queryset(self, request):
|
|
|
|
qs = super(ProblemAdmin, self).get_queryset(request)
|
2019-04-30 22:13:43 +02:00
|
|
|
return qs.select_related('autor', 'opravovatel', 'cislo_reseni')
|
2015-05-21 22:18:44 +02:00
|
|
|
|
2015-05-21 22:30:35 +02:00
|
|
|
def pocet_reseni(self, obj):
|
|
|
|
return obj.pocet_reseni
|
2015-05-21 22:18:44 +02:00
|
|
|
|
2015-05-27 09:20:15 +02:00
|
|
|
class ProblemNavrhAdmin(ProblemAdmin):
|
2015-10-19 10:08:56 +02:00
|
|
|
list_display = ['nazev', 'typ', 'stav', 'autor', 'timestamp']
|
2015-09-17 22:01:53 +02:00
|
|
|
list_filter = ['typ', 'zamereni', 'timestamp', 'stav']
|
2015-05-27 09:20:15 +02:00
|
|
|
|
|
|
|
def get_queryset(self, request):
|
|
|
|
qs = super(ProblemNavrhAdmin, self).get_queryset(request)
|
|
|
|
return qs.filter(stav__in=[Problem.STAV_NAVRH, Problem.STAV_SMAZANY])
|
2015-05-14 16:18:43 +02:00
|
|
|
|
2015-09-24 11:11:54 +02:00
|
|
|
get_form = get_form_predvypln_autora
|
|
|
|
|
|
|
|
|
2019-04-23 23:26:37 +02:00
|
|
|
#FIXME
|
|
|
|
#create_modeladmin(ProblemNavrhAdmin, Problem, 'ProblemNavrh', verbose_name=u'Problém (návrh)', verbose_name_plural=u'Problémy (návrhy)')
|
2015-05-27 09:20:15 +02:00
|
|
|
|
2017-03-26 20:34:03 +02:00
|
|
|
|
2015-05-27 09:20:15 +02:00
|
|
|
class ProblemZadanyAdmin(ProblemAdmin):
|
2017-04-21 22:43:08 +02:00
|
|
|
list_display = [
|
|
|
|
'nazev',
|
|
|
|
'typ',
|
|
|
|
'cislo_zadani_link',
|
|
|
|
'cislo_reseni_link',
|
|
|
|
'autor',
|
|
|
|
'opravovatel',
|
|
|
|
'kod',
|
|
|
|
'verejne'
|
|
|
|
]
|
2017-03-26 20:34:03 +02:00
|
|
|
list_filter = [
|
|
|
|
'typ', 'zamereni', 'cislo_zadani__cislo', 'cislo_zadani__rocnik'
|
|
|
|
]
|
2016-02-16 00:04:26 +01:00
|
|
|
|
2017-04-21 22:43:08 +02:00
|
|
|
def cislo_zadani_link(self, obj):
|
2017-04-21 22:56:46 +02:00
|
|
|
if not obj.cislo_zadani:
|
|
|
|
return ""
|
2017-04-21 22:43:08 +02:00
|
|
|
return mark_safe('<a href="{}">{}</a>'.format(
|
|
|
|
reverse("admin:seminar_cislo_change", args=(obj.cislo_zadani.pk,)),
|
|
|
|
obj.cislo_zadani
|
|
|
|
))
|
|
|
|
cislo_zadani_link.short_description = u'Číslo zadání'
|
|
|
|
|
|
|
|
# TODO pokud se budou odkazy v adminu více používat, možná by se hodilo je
|
|
|
|
# nějak zjednodušit, např. tímto?
|
|
|
|
# https://github.com/gitaarik/django-admin-relation-links
|
|
|
|
def cislo_reseni_link(self, obj):
|
2017-04-21 22:56:46 +02:00
|
|
|
if not obj.cislo_reseni:
|
|
|
|
return ""
|
2017-04-21 22:43:08 +02:00
|
|
|
return mark_safe('<a href="{}">{}</a>'.format(
|
|
|
|
reverse("admin:seminar_cislo_change", args=(obj.cislo_reseni.pk,)),
|
|
|
|
obj.cislo_reseni
|
|
|
|
))
|
|
|
|
cislo_reseni_link.short_description = u'Číslo řešení'
|
|
|
|
|
2016-02-16 00:04:26 +01:00
|
|
|
def get_inline_instances(self, request, obj=None):
|
|
|
|
if obj and obj.typ == Problem.TYP_ULOHA:
|
|
|
|
inlines = [ReseniKProblemuInline, PohadkaKProblemuInline]
|
|
|
|
else:
|
|
|
|
inlines = [ReseniKProblemuInline]
|
|
|
|
|
|
|
|
return [inline(self.model, self.admin_site) for inline in inlines]
|
2015-05-27 09:20:15 +02:00
|
|
|
|
|
|
|
def get_queryset(self, request):
|
|
|
|
qs = super(ProblemZadanyAdmin, self).get_queryset(request)
|
2017-03-26 20:34:03 +02:00
|
|
|
return qs.filter(stav=Problem.STAV_ZADANY)
|
2015-05-27 09:20:15 +02:00
|
|
|
|
2015-09-24 11:11:54 +02:00
|
|
|
get_form = get_form_predvypln_autora
|
|
|
|
|
2019-04-23 23:26:37 +02:00
|
|
|
#FIXME
|
|
|
|
#create_modeladmin(ProblemZadanyAdmin, Problem, 'ProblemZadany', verbose_name=u'Problém (zadaný)', verbose_name_plural=u'Problémy (zadané)')
|
2015-05-14 16:18:43 +02:00
|
|
|
|
2015-05-27 09:20:15 +02:00
|
|
|
#admin.site.register(Problem, ProblemAdmin)
|
2015-05-14 16:18:43 +02:00
|
|
|
|
2016-02-04 19:57:03 +01:00
|
|
|
### Prispevek (k tematkum)
|
|
|
|
|
2019-04-23 23:26:37 +02:00
|
|
|
#class PrispevekAdminForm(forms.ModelForm):
|
|
|
|
# text_org = forms.CharField(widget=CKEditorUploadingWidget(), required=False,
|
|
|
|
# **field_labels(Prispevek, 'text_org'))
|
|
|
|
# text_resitel = forms.CharField(widget=CKEditorUploadingWidget(), required=False,
|
|
|
|
# **field_labels(Prispevek, 'text_resitel'))
|
|
|
|
#
|
|
|
|
# class Meta:
|
|
|
|
# model = Prispevek
|
|
|
|
# exclude = []
|
|
|
|
#
|
|
|
|
#class PrispevekAdmin(VersionAdmin):
|
|
|
|
# form = PrispevekAdminForm
|
|
|
|
# list_display = ['nazev', 'problem', 'reseni', 'zverejnit']
|
|
|
|
#
|
|
|
|
#admin.site.register(Prispevek, PrispevekAdmin)
|
2016-02-04 19:57:03 +01:00
|
|
|
|
2015-05-14 16:18:43 +02:00
|
|
|
### Soustredeni
|
|
|
|
|
2015-05-26 23:09:37 +02:00
|
|
|
class SoustredeniAdminForm(forms.ModelForm):
|
2018-09-14 22:24:52 +02:00
|
|
|
text = forms.CharField(widget=CKEditorUploadingWidget(), required=False, **field_labels(Soustredeni, 'text'))
|
2015-05-26 23:09:37 +02:00
|
|
|
class Meta:
|
|
|
|
model = Soustredeni
|
|
|
|
exclude = []
|
|
|
|
|
2015-10-25 13:17:49 +01:00
|
|
|
class SoustredeniAdmin(VersionAdmin):
|
2015-05-26 23:09:37 +02:00
|
|
|
form = SoustredeniAdminForm
|
2015-05-14 16:18:43 +02:00
|
|
|
fieldsets = [
|
2019-04-30 21:39:22 +02:00
|
|
|
(None, {'fields': ['rocnik', 'misto', 'typ', 'verejne_db', 'exportovat', 'text']}),
|
|
|
|
('Data', {'fields': ['datum_zacatku', 'datum_konce']}),
|
2015-05-14 16:18:43 +02:00
|
|
|
]
|
2015-07-23 20:42:50 +02:00
|
|
|
list_display = ['rocnik', 'misto', 'datum_zacatku', 'typ', 'exportovat', 'verejne']
|
2015-12-22 15:22:40 +01:00
|
|
|
inlines = [Soustredeni_UcastniciInline, Soustredeni_OrganizatoriInline]
|
2015-07-23 20:42:50 +02:00
|
|
|
list_filter = ['typ', 'rocnik']
|
2015-10-22 08:55:42 +02:00
|
|
|
view_on_site = Soustredeni.verejne_url
|
2015-07-23 21:32:44 +02:00
|
|
|
actions = [
|
|
|
|
make_set_action('verejne_db', True, u'Zveřejnit soustředění'),
|
|
|
|
make_set_action('verejne_db', False, u'Skrýt (zneveřejnit) soustředění'),
|
|
|
|
make_set_action('exportovat', True, u'Nastavit pro AESOP export'),
|
|
|
|
make_set_action('exportovat', False, u'Skrýt pro AESOP export'),
|
|
|
|
]
|
2015-05-14 16:18:43 +02:00
|
|
|
|
|
|
|
admin.site.register(Soustredeni, SoustredeniAdmin)
|
2015-05-21 17:44:51 +02:00
|
|
|
|
2016-10-05 08:55:28 +02:00
|
|
|
### Konfery
|
|
|
|
class KonferaAdminForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model=Konfera
|
|
|
|
exclude = []
|
|
|
|
|
|
|
|
class KonferaAdmin(VersionAdmin):
|
|
|
|
form = KonferaAdminForm
|
|
|
|
list_filter = ['soustredeni']
|
|
|
|
list_display = ['nazev','soustredeni','organizator','typ_prezentace']
|
|
|
|
# inlines = [Konfera_UcastniciInline]
|
|
|
|
|
|
|
|
admin.site.register(Konfera,KonferaAdmin)
|
|
|
|
|
2015-06-23 11:32:16 +02:00
|
|
|
### Novinky
|
|
|
|
|
2015-06-23 11:46:45 +02:00
|
|
|
class NovinkyAdminForm(forms.ModelForm):
|
2018-09-14 22:24:52 +02:00
|
|
|
text = forms.CharField(widget=CKEditorUploadingWidget(), required=False,
|
2015-06-23 11:46:45 +02:00
|
|
|
**field_labels(Novinky, 'text'))
|
2015-09-24 00:43:05 +02:00
|
|
|
autor = UserModelChoiceField(User.objects.filter(is_staff=True))
|
|
|
|
|
2015-06-23 11:46:45 +02:00
|
|
|
class Meta:
|
|
|
|
model = Novinky
|
|
|
|
exclude = []
|
|
|
|
|
2015-09-10 20:09:49 +02:00
|
|
|
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'
|
|
|
|
|
|
|
|
|
2015-10-25 13:17:49 +01:00
|
|
|
class NovinkyAdmin(VersionAdmin):
|
2015-06-23 11:46:45 +02:00
|
|
|
form = NovinkyAdminForm
|
2015-09-10 20:09:49 +02:00
|
|
|
list_display = ['datum', 'autor', 'text', 'zverejneno', 'obrazek']
|
|
|
|
actions = [zverejnit_novinky, zneverejnit_novinky]
|
2015-06-23 11:46:45 +02:00
|
|
|
|
2015-09-24 11:11:54 +02:00
|
|
|
get_form = get_form_predvypln_autora
|
|
|
|
|
2015-09-12 00:22:17 +02:00
|
|
|
|
2015-06-23 11:32:16 +02:00
|
|
|
admin.site.register(Novinky, NovinkyAdmin)
|
2015-06-25 11:01:39 +02:00
|
|
|
|
|
|
|
### Organizator
|
|
|
|
|
2015-07-05 09:49:00 +02:00
|
|
|
def jmeno_organizatora(obj):
|
2015-07-05 10:12:47 +02:00
|
|
|
''' vraci jmeno organizatora '''
|
2015-07-05 10:21:19 +02:00
|
|
|
jmeno = obj.user.first_name
|
|
|
|
if obj.prezdivka:
|
|
|
|
jmeno = jmeno + ' "' + obj.prezdivka + '"'
|
|
|
|
jmeno = jmeno + ' ' + obj.user.last_name
|
2015-07-05 10:31:35 +02:00
|
|
|
if jmeno == ' ': # zobrazeni bezejmennych orgu
|
|
|
|
return 'org'
|
2015-07-05 10:21:19 +02:00
|
|
|
return jmeno
|
2015-07-05 09:49:00 +02:00
|
|
|
jmeno_organizatora.short_description = 'Jméno organizátora'
|
|
|
|
|
|
|
|
def je_organizator_aktivni(obj):
|
2015-07-05 10:12:47 +02:00
|
|
|
''' zjisti, zda-li je organizator aktivni '''
|
2015-07-05 09:49:00 +02:00
|
|
|
return obj.user.is_active
|
|
|
|
je_organizator_aktivni.short_description = 'Aktivní'
|
|
|
|
je_organizator_aktivni.boolean = True
|
|
|
|
|
2015-07-05 10:12:47 +02:00
|
|
|
def zaktivovat_organizatory(modeladmin, request, queryset):
|
|
|
|
''' vybrane organizatory oznaci jako aktivni '''
|
|
|
|
for org in queryset:
|
|
|
|
org.user.is_active = True
|
|
|
|
org.user.save()
|
|
|
|
zaktivovat_organizatory.short_description = 'Zaktivovat organizátory'
|
|
|
|
|
|
|
|
def deaktivovat_organizatory(modeladmin, request, queryset):
|
|
|
|
''' deaktivuje vybrane organizatory '''
|
|
|
|
for org in queryset:
|
|
|
|
org.user.is_active = False
|
|
|
|
org.user.save()
|
|
|
|
deaktivovat_organizatory.short_description = 'Deaktivovat organizátory'
|
|
|
|
|
|
|
|
|
2015-06-25 11:01:39 +02:00
|
|
|
@admin.register(Organizator)
|
2015-10-25 13:17:49 +01:00
|
|
|
class OrganizatorAdmin(VersionAdmin):
|
2019-04-23 23:26:37 +02:00
|
|
|
list_filter = ['organizuje_do']
|
2015-07-05 09:49:00 +02:00
|
|
|
list_display = [jmeno_organizatora, je_organizator_aktivni,]
|
2015-07-05 10:12:47 +02:00
|
|
|
actions = [zaktivovat_organizatory, deaktivovat_organizatory,]
|
2015-06-25 11:01:39 +02:00
|
|
|
|