|
|
|
from django.contrib import admin
|
|
|
|
from django.forms import widgets
|
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
from seminar.models.soustredeni import *
|
|
|
|
|
|
|
|
|
|
|
|
class SoustredeniUcastniciInline(admin.TabularInline):
|
|
|
|
model = 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 = 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(Soustredeni)
|
|
|
|
class SoustredeniAdmin(admin.ModelAdmin):
|
|
|
|
model = Soustredeni
|
|
|
|
inline_type = 'tabular'
|
|
|
|
inlines = [SoustredeniUcastniciInline, SoustredeniOrganizatoriInline]
|
|
|
|
|