|
@ -18,13 +18,13 @@ from autocomplete_light import shortcuts as autocomplete_light |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UserModelChoiceField(forms.ModelChoiceField): |
|
|
class UserModelChoiceField(forms.ModelChoiceField): |
|
|
u"""Vlastní ModelChoiceField pro uživatele. Zobrazí kromě loginu i jméno. |
|
|
"""Vlastní ModelChoiceField pro uživatele. Zobrazí kromě loginu i jméno. |
|
|
""" |
|
|
""" |
|
|
def label_from_instance(self, obj): |
|
|
def label_from_instance(self, obj): |
|
|
return u"{} ({})".format(obj.get_full_name(), obj.username) |
|
|
return "{} ({})".format(obj.get_full_name(), obj.username) |
|
|
|
|
|
|
|
|
def get_form_predvypln_autora(self, request, obj=None, *args, **kwargs): |
|
|
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. |
|
|
"""get_form fce pro Adminy. Předvyplňí přihlášeného uživatele jako autora. |
|
|
""" |
|
|
""" |
|
|
form = super(self.__class__, self).get_form(request, *args, **kwargs) |
|
|
form = super(self.__class__, self).get_form(request, *args, **kwargs) |
|
|
form.base_fields['autor'].initial = request.user.id |
|
|
form.base_fields['autor'].initial = request.user.id |
|
@ -32,7 +32,7 @@ def get_form_predvypln_autora(self, request, obj=None, *args, **kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def make_set_action(atribut, hodnota, nazev): |
|
|
def make_set_action(atribut, hodnota, nazev): |
|
|
u""" |
|
|
""" |
|
|
Pomocnik pro rychle vytvareni hromadnych admin akci ktere jen nastavuji |
|
|
Pomocnik pro rychle vytvareni hromadnych admin akci ktere jen nastavuji |
|
|
atribut (dany jako string) na danou hodnotu. |
|
|
atribut (dany jako string) na danou hodnotu. |
|
|
nazev je krátký popis akce pro admin rozhraní.""" |
|
|
nazev je krátký popis akce pro admin rozhraní.""" |
|
@ -214,10 +214,10 @@ class ResitelAdmin(VersionAdmin): |
|
|
fk_name = 'osoba' |
|
|
fk_name = 'osoba' |
|
|
fieldsets = [ |
|
|
fieldsets = [ |
|
|
(None, {'fields': ['jmeno', 'prijmeni', 'user']}), |
|
|
(None, {'fields': ['jmeno', 'prijmeni', 'user']}), |
|
|
(u'Škola', {'fields': ['skola', 'rok_maturity']}), |
|
|
('Škola', {'fields': ['skola', 'rok_maturity']}), |
|
|
(u'Seminář', {'fields': ['datum_souhlasu_udaje', 'datum_souhlasu_zasilani', 'datum_prihlaseni', 'zasilat']}), |
|
|
('Seminář', {'fields': ['datum_souhlasu_udaje', 'datum_souhlasu_zasilani', 'datum_prihlaseni', 'zasilat']}), |
|
|
(u'Osobní údaje', {'fields': ['pohlavi_muz', 'datum_narozeni', 'email', 'telefon']}), |
|
|
('Osobní údaje', {'fields': ['pohlavi_muz', 'datum_narozeni', 'email', 'telefon']}), |
|
|
(u'Adresa', {'fields': ['ulice', 'mesto', 'psc', 'stat']}), |
|
|
('Adresa', {'fields': ['ulice', 'mesto', 'psc', 'stat']}), |
|
|
] |
|
|
] |
|
|
list_display = ['osoba__jmeno', 'osoba__prijmeni', 'osoba__user', 'osoba__pohlavi_muz', 'skola', 'rok_maturity', 'pocet_reseni'] |
|
|
list_display = ['osoba__jmeno', 'osoba__prijmeni', 'osoba__user', 'osoba__pohlavi_muz', 'skola', 'rok_maturity', 'pocet_reseni'] |
|
|
list_filter = ['osoba__pohlavi_muz', 'rok_maturity', 'zasilat'] |
|
|
list_filter = ['osoba__pohlavi_muz', 'rok_maturity', 'zasilat'] |
|
@ -262,8 +262,8 @@ admin.site.register(Resitel, ResitelAdmin) |
|
|
class SkolaAdmin(VersionAdmin): |
|
|
class SkolaAdmin(VersionAdmin): |
|
|
fieldsets = [ |
|
|
fieldsets = [ |
|
|
(None, {'fields': ['nazev', 'kratky_nazev', 'je_zs', 'je_ss']}), |
|
|
(None, {'fields': ['nazev', 'kratky_nazev', 'je_zs', 'je_ss']}), |
|
|
(u'Interní ID', {'fields': ['aesop_id', 'izo'], 'classes': ['collapse']}), |
|
|
('Interní ID', {'fields': ['aesop_id', 'izo'], 'classes': ['collapse']}), |
|
|
(u'Adresa', {'fields': ['ulice', 'mesto', 'psc', 'stat']}), |
|
|
('Adresa', {'fields': ['ulice', 'mesto', 'psc', 'stat']}), |
|
|
(None, {'fields': ['poznamka']}), |
|
|
(None, {'fields': ['poznamka']}), |
|
|
] |
|
|
] |
|
|
list_display = ['nazev', 'aesop_id', 'mesto', 'ulice', 'stat', 'je_zs', 'je_ss'] |
|
|
list_display = ['nazev', 'aesop_id', 'mesto', 'ulice', 'stat', 'je_zs', 'je_ss'] |
|
@ -328,8 +328,8 @@ class RocnikAdmin(VersionAdmin): |
|
|
inlines = [CisloInline] |
|
|
inlines = [CisloInline] |
|
|
view_on_site = Rocnik.verejne_url |
|
|
view_on_site = Rocnik.verejne_url |
|
|
actions = [ |
|
|
actions = [ |
|
|
make_set_action('exportovat', True, u'Nastavit pro AESOP export'), |
|
|
make_set_action('exportovat', True, 'Nastavit pro AESOP export'), |
|
|
make_set_action('exportovat', False, u'Skrýt pro AESOP export'), |
|
|
make_set_action('exportovat', False, 'Skrýt pro AESOP export'), |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
admin.site.register(Rocnik, RocnikAdmin) |
|
|
admin.site.register(Rocnik, RocnikAdmin) |
|
@ -341,7 +341,7 @@ admin.site.register(Rocnik, RocnikAdmin) |
|
|
# readonly_fields = ['timestamp', 'reseni'] |
|
|
# readonly_fields = ['timestamp', 'reseni'] |
|
|
# fieldsets = [ |
|
|
# fieldsets = [ |
|
|
# (None, {'fields': ['reseni', 'soubor', 'timestamp']}), |
|
|
# (None, {'fields': ['reseni', 'soubor', 'timestamp']}), |
|
|
# (u'Poznámky', {'fields': ['poznamka']}), |
|
|
# ('Poznámky', {'fields': ['poznamka']}), |
|
|
# ] |
|
|
# ] |
|
|
# list_display = ['reseni', 'soubor', 'timestamp'] |
|
|
# list_display = ['reseni', 'soubor', 'timestamp'] |
|
|
# list_filter = ['reseni', 'timestamp'] |
|
|
# list_filter = ['reseni', 'timestamp'] |
|
@ -356,7 +356,7 @@ class ReseniAdmin(VersionAdmin): |
|
|
#form = autocomplete_light.modelform_factory(Reseni, autocomplete_fields=['problem', 'resitele'], fields=['problem', 'resitele']) |
|
|
#form = autocomplete_light.modelform_factory(Reseni, autocomplete_fields=['problem', 'resitele'], fields=['problem', 'resitele']) |
|
|
fieldsets = [ |
|
|
fieldsets = [ |
|
|
(None, {'fields': ['problem__set', 'resitele__set', 'forma', 'cas_doruceni']}), |
|
|
(None, {'fields': ['problem__set', 'resitele__set', 'forma', 'cas_doruceni']}), |
|
|
(u'Poznámky', {'fields': ['poznamka']}), |
|
|
('Poznámky', {'fields': ['poznamka']}), |
|
|
] |
|
|
] |
|
|
readonly_fields = ['cas_doruceni'] |
|
|
readonly_fields = ['cas_doruceni'] |
|
|
list_display = [ResitelInline, 'forma', 'cas_doruceni'] |
|
|
list_display = [ResitelInline, 'forma', 'cas_doruceni'] |
|
@ -400,11 +400,11 @@ class PohadkaAdmin(VersionAdmin): |
|
|
|
|
|
|
|
|
def get_kod_ulohy(self, obj): |
|
|
def get_kod_ulohy(self, obj): |
|
|
return obj.uloha.kod_v_rocniku() |
|
|
return obj.uloha.kod_v_rocniku() |
|
|
get_kod_ulohy.short_description = u'Kód úlohy' |
|
|
get_kod_ulohy.short_description = 'Kód úlohy' |
|
|
|
|
|
|
|
|
def get_rocnik(self, obj): |
|
|
def get_rocnik(self, obj): |
|
|
return obj.uloha.cislo_zadani.rocnik.rocnik |
|
|
return obj.uloha.cislo_zadani.rocnik.rocnik |
|
|
get_rocnik.short_description = u'Ročník' |
|
|
get_rocnik.short_description = 'Ročník' |
|
|
|
|
|
|
|
|
list_display = [ |
|
|
list_display = [ |
|
|
'__str__', |
|
|
'__str__', |
|
@ -477,7 +477,7 @@ class ProblemAdmin(VersionAdmin): |
|
|
form = ProblemAdminForm |
|
|
form = ProblemAdminForm |
|
|
fieldsets = [ |
|
|
fieldsets = [ |
|
|
(None, {'fields': ['nazev', 'typ', 'stav', 'autor', 'zamereni', 'body', 'timestamp', 'import_dakos_id']}), |
|
|
(None, {'fields': ['nazev', 'typ', 'stav', 'autor', 'zamereni', 'body', 'timestamp', 'import_dakos_id']}), |
|
|
(u'Vydání', {'fields': ['kod', 'cislo_reseni', 'opravovatel',]}), |
|
|
('Vydání', {'fields': ['kod', 'cislo_reseni', 'opravovatel',]}), |
|
|
(None, {'fields': ['text_zadani', 'text_reseni', 'text_org',]}), |
|
|
(None, {'fields': ['text_zadani', 'text_reseni', 'text_org',]}), |
|
|
] |
|
|
] |
|
|
list_select_related = True |
|
|
list_select_related = True |
|
@ -506,7 +506,7 @@ class ProblemNavrhAdmin(ProblemAdmin): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#FIXME |
|
|
#FIXME |
|
|
#create_modeladmin(ProblemNavrhAdmin, Problem, 'ProblemNavrh', verbose_name=u'Problém (návrh)', verbose_name_plural=u'Problémy (návrhy)') |
|
|
#create_modeladmin(ProblemNavrhAdmin, Problem, 'ProblemNavrh', verbose_name='Problém (návrh)', verbose_name_plural='Problémy (návrhy)') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProblemZadanyAdmin(ProblemAdmin): |
|
|
class ProblemZadanyAdmin(ProblemAdmin): |
|
@ -531,7 +531,7 @@ class ProblemZadanyAdmin(ProblemAdmin): |
|
|
reverse("admin:seminar_cislo_change", args=(obj.cislo_zadani.pk,)), |
|
|
reverse("admin:seminar_cislo_change", args=(obj.cislo_zadani.pk,)), |
|
|
obj.cislo_zadani |
|
|
obj.cislo_zadani |
|
|
)) |
|
|
)) |
|
|
cislo_zadani_link.short_description = u'Číslo zadání' |
|
|
cislo_zadani_link.short_description = 'Číslo zadání' |
|
|
|
|
|
|
|
|
# TODO pokud se budou odkazy v adminu více používat, možná by se hodilo je |
|
|
# TODO pokud se budou odkazy v adminu více používat, možná by se hodilo je |
|
|
# nějak zjednodušit, např. tímto? |
|
|
# nějak zjednodušit, např. tímto? |
|
@ -543,7 +543,7 @@ class ProblemZadanyAdmin(ProblemAdmin): |
|
|
reverse("admin:seminar_cislo_change", args=(obj.cislo_reseni.pk,)), |
|
|
reverse("admin:seminar_cislo_change", args=(obj.cislo_reseni.pk,)), |
|
|
obj.cislo_reseni |
|
|
obj.cislo_reseni |
|
|
)) |
|
|
)) |
|
|
cislo_reseni_link.short_description = u'Číslo řešení' |
|
|
cislo_reseni_link.short_description = 'Číslo řešení' |
|
|
|
|
|
|
|
|
def get_inline_instances(self, request, obj=None): |
|
|
def get_inline_instances(self, request, obj=None): |
|
|
if obj and obj.typ == Problem.TYP_ULOHA: |
|
|
if obj and obj.typ == Problem.TYP_ULOHA: |
|
@ -560,7 +560,7 @@ class ProblemZadanyAdmin(ProblemAdmin): |
|
|
get_form = get_form_predvypln_autora |
|
|
get_form = get_form_predvypln_autora |
|
|
|
|
|
|
|
|
#FIXME |
|
|
#FIXME |
|
|
#create_modeladmin(ProblemZadanyAdmin, Problem, 'ProblemZadany', verbose_name=u'Problém (zadaný)', verbose_name_plural=u'Problémy (zadané)') |
|
|
#create_modeladmin(ProblemZadanyAdmin, Problem, 'ProblemZadany', verbose_name='Problém (zadaný)', verbose_name_plural='Problémy (zadané)') |
|
|
|
|
|
|
|
|
#admin.site.register(Problem, ProblemAdmin) |
|
|
#admin.site.register(Problem, ProblemAdmin) |
|
|
|
|
|
|
|
@ -601,10 +601,10 @@ class SoustredeniAdmin(VersionAdmin): |
|
|
list_filter = ['typ', 'rocnik'] |
|
|
list_filter = ['typ', 'rocnik'] |
|
|
view_on_site = Soustredeni.verejne_url |
|
|
view_on_site = Soustredeni.verejne_url |
|
|
actions = [ |
|
|
actions = [ |
|
|
make_set_action('verejne_db', True, u'Zveřejnit soustředění'), |
|
|
make_set_action('verejne_db', True, 'Zveřejnit soustředění'), |
|
|
make_set_action('verejne_db', False, u'Skrýt (zneveřejnit) soustředění'), |
|
|
make_set_action('verejne_db', False, 'Skrýt (zneveřejnit) soustředění'), |
|
|
make_set_action('exportovat', True, u'Nastavit pro AESOP export'), |
|
|
make_set_action('exportovat', True, 'Nastavit pro AESOP export'), |
|
|
make_set_action('exportovat', False, u'Skrýt pro AESOP export'), |
|
|
make_set_action('exportovat', False, 'Skrýt pro AESOP export'), |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
admin.site.register(Soustredeni, SoustredeniAdmin) |
|
|
admin.site.register(Soustredeni, SoustredeniAdmin) |
|
|