Merge branch 'python3' of gimli.ms.mff.cuni.cz:/akce/mam/git/mamweb into python3
This commit is contained in:
commit
f4763a3040
1 changed files with 38 additions and 7 deletions
|
@ -76,11 +76,20 @@ def create_modeladmin(modeladmin, model, name = None, verbose_name = None, verbo
|
||||||
|
|
||||||
class ResitelInline(admin.TabularInline):
|
class ResitelInline(admin.TabularInline):
|
||||||
model = Resitel
|
model = Resitel
|
||||||
fields = ['jmeno', 'prijmeni', 'skola', 'mesto', 'rok_maturity', ]
|
fields = ['osoba_jmeno', 'osoba_prijmeni', 'skola', 'osoba_mesto', 'rok_maturity', ]
|
||||||
readonly_fields = ['jmeno', 'prijmeni', 'skola', 'mesto', 'rok_maturity', ]
|
readonly_fields = ['osoba_jmeno', 'osoba_prijmeni', 'skola', 'osoba_mesto', 'rok_maturity', ]
|
||||||
extra = 0
|
extra = 0
|
||||||
view_on_site = False
|
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
|
def has_add_permission(self, req): return False
|
||||||
|
|
||||||
|
|
||||||
|
@ -202,6 +211,7 @@ class Soustredeni_OrganizatoriInline(admin.TabularInline):
|
||||||
|
|
||||||
class ResitelAdmin(VersionAdmin):
|
class ResitelAdmin(VersionAdmin):
|
||||||
form = autocomplete_light.modelform_factory(Resitel, autocomplete_fields=['skola'], fields=['skola'])
|
form = autocomplete_light.modelform_factory(Resitel, autocomplete_fields=['skola'], fields=['skola'])
|
||||||
|
fk_name = 'osoba'
|
||||||
fieldsets = [
|
fieldsets = [
|
||||||
(None, {'fields': ['jmeno', 'prijmeni', 'user']}),
|
(None, {'fields': ['jmeno', 'prijmeni', 'user']}),
|
||||||
(u'Škola', {'fields': ['skola', 'rok_maturity']}),
|
(u'Škola', {'fields': ['skola', 'rok_maturity']}),
|
||||||
|
@ -209,12 +219,33 @@ class ResitelAdmin(VersionAdmin):
|
||||||
(u'Osobní údaje', {'fields': ['pohlavi_muz', 'datum_narozeni', 'email', 'telefon']}),
|
(u'Osobní údaje', {'fields': ['pohlavi_muz', 'datum_narozeni', 'email', 'telefon']}),
|
||||||
(u'Adresa', {'fields': ['ulice', 'mesto', 'psc', 'stat']}),
|
(u'Adresa', {'fields': ['ulice', 'mesto', 'psc', 'stat']}),
|
||||||
]
|
]
|
||||||
list_display = ['jmeno', 'prijmeni', 'user', '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 = ['pohlavi_muz', 'rok_maturity', 'zasilat']
|
list_filter = ['osoba__pohlavi_muz', 'rok_maturity', 'zasilat']
|
||||||
search_fields = ['jmeno', 'prijmeni', 'ulice', 'mesto', 'email']
|
search_fields = ['osoba__jmeno', 'osoba__prijmeni', 'osoba__ulice', 'osoba__mesto', 'osoba__email']
|
||||||
inlines = [ReseniKResiteliInline]
|
# inlines = [ReseniKResiteliInline] # FIXME:
|
||||||
view_on_site = False
|
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):
|
def get_queryset(self, request):
|
||||||
qs = super(ResitelAdmin, self).get_queryset(request)
|
qs = super(ResitelAdmin, self).get_queryset(request)
|
||||||
return qs.select_related('skola', 'user').annotate(pocet_reseni=Count('reseni'))
|
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_display = [ResitelInline, 'forma', 'cas_doruceni']
|
||||||
list_filter = ['cas_doruceni', 'forma']
|
list_filter = ['cas_doruceni', 'forma']
|
||||||
search_fields = []
|
search_fields = []
|
||||||
inlines = [PrilohaReseniInline,ResitelInline]
|
inlines = [PrilohaReseniInline] # FIXME: odmazáno ProblemInline,ResitelInline
|
||||||
view_on_site = False
|
view_on_site = False
|
||||||
|
|
||||||
def get_queryset(self, request):
|
def get_queryset(self, request):
|
||||||
|
|
Loading…
Reference in a new issue