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.
43 lines
1.3 KiB
43 lines
1.3 KiB
from django.contrib import admin
|
|
from django.forms import widgets
|
|
from django.db import models
|
|
|
|
from seminar.models import soustredeni as m
|
|
|
|
|
|
class SoustredeniUcastniciInline(admin.TabularInline):
|
|
model = m.Soustredeni_Ucastnici
|
|
extra = 1
|
|
fields = ['resitel','poznamka']
|
|
autocomplete_fields = ['resitel']
|
|
ordering = ['resitel__osoba__jmeno', 'resitel__osoba__prijmeni']
|
|
formfield_overrides = {
|
|
models.TextField: {'widget': widgets.TextInput}
|
|
}
|
|
|
|
def get_queryset(self,request):
|
|
qs = super().get_queryset(request)
|
|
return qs.select_related('resitel','soustredeni')
|
|
|
|
|
|
class SoustredeniOrganizatoriInline(admin.TabularInline):
|
|
model = m.Soustredeni.organizatori.through
|
|
extra = 1
|
|
fields = ['organizator','poznamka']
|
|
autocomplete_fields = ['organizator']
|
|
ordering = ['organizator__osoba__jmeno','organizator__prijmeni']
|
|
formfield_overrides = {
|
|
models.TextField: {'widget': widgets.TextInput}
|
|
}
|
|
|
|
def get_queryset(self,request):
|
|
qs = super().get_queryset(request)
|
|
return qs.select_related('organizator', 'soustredeni')
|
|
|
|
|
|
@admin.register(m.Soustredeni)
|
|
class SoustredeniAdmin(admin.ModelAdmin):
|
|
model = m.Soustredeni
|
|
inline_type = 'tabular'
|
|
inlines = [SoustredeniUcastniciInline, SoustredeniOrganizatoriInline]
|
|
|
|
|