|
|
|
from django.contrib import admin
|
|
|
|
from django.forms import widgets
|
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
import soustredeni.models 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__osoba__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]
|
|
|
|
|