|
|
@ -76,11 +76,20 @@ def create_modeladmin(modeladmin, model, name = None, verbose_name = None, verbo |
|
|
|
|
|
|
|
class ResitelInline(admin.TabularInline): |
|
|
|
model = Resitel |
|
|
|
fields = ['jmeno', 'prijmeni', 'skola', 'mesto', 'rok_maturity', ] |
|
|
|
readonly_fields = ['jmeno', 'prijmeni', 'skola', 'mesto', 'rok_maturity', ] |
|
|
|
fields = ['osoba_jmeno', 'osoba_prijmeni', 'skola', 'osoba_mesto', 'rok_maturity', ] |
|
|
|
readonly_fields = ['osoba_jmeno', 'osoba_prijmeni', 'skola', 'osoba_mesto', 'rok_maturity', ] |
|
|
|
extra = 0 |
|
|
|
view_on_site = False |
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
def has_add_permission(self, req): return False |
|
|
|
|
|
|
|
|
|
|
@ -202,6 +211,7 @@ class Soustredeni_OrganizatoriInline(admin.TabularInline): |
|
|
|
|
|
|
|
class ResitelAdmin(VersionAdmin): |
|
|
|
form = autocomplete_light.modelform_factory(Resitel, autocomplete_fields=['skola'], fields=['skola']) |
|
|
|
fk_name = 'osoba' |
|
|
|
fieldsets = [ |
|
|
|
(None, {'fields': ['jmeno', 'prijmeni', 'user']}), |
|
|
|
(u'Škola', {'fields': ['skola', 'rok_maturity']}), |
|
|
@ -209,12 +219,33 @@ class ResitelAdmin(VersionAdmin): |
|
|
|
(u'Osobní údaje', {'fields': ['pohlavi_muz', 'datum_narozeni', 'email', 'telefon']}), |
|
|
|
(u'Adresa', {'fields': ['ulice', 'mesto', 'psc', 'stat']}), |
|
|
|
] |
|
|
|
list_display = ['jmeno', 'prijmeni', 'user', 'pohlavi_muz', 'skola', 'rok_maturity', 'pocet_reseni'] |
|
|
|
list_filter = ['pohlavi_muz', 'rok_maturity', 'zasilat'] |
|
|
|
search_fields = ['jmeno', 'prijmeni', 'ulice', 'mesto', 'email'] |
|
|
|
inlines = [ReseniKResiteliInline] |
|
|
|
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'] |
|
|
|
# inlines = [ReseniKResiteliInline] # FIXME: |
|
|
|
view_on_site = False |
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
def get_queryset(self, request): |
|
|
|
qs = super(ResitelAdmin, self).get_queryset(request) |
|
|
|
return qs.select_related('skola', 'user').annotate(pocet_reseni=Count('reseni')) |
|
|
@ -331,7 +362,7 @@ class ReseniAdmin(VersionAdmin): |
|
|
|
list_display = [ResitelInline, 'forma', 'cas_doruceni'] |
|
|
|
list_filter = ['cas_doruceni', 'forma'] |
|
|
|
search_fields = [] |
|
|
|
inlines = [PrilohaReseniInline,ResitelInline] |
|
|
|
inlines = [PrilohaReseniInline] # FIXME: odmazáno ProblemInline,ResitelInline |
|
|
|
view_on_site = False |
|
|
|
|
|
|
|
def get_queryset(self, request): |
|
|
|