|
|
@ -1,11 +1,14 @@ |
|
|
|
from django.contrib import admin |
|
|
|
from django.contrib.auth.models import Permission |
|
|
|
from django.db import models |
|
|
|
from django.forms import widgets |
|
|
|
|
|
|
|
from polymorphic.admin import PolymorphicParentModelAdmin, PolymorphicChildModelAdmin, PolymorphicChildModelFilter |
|
|
|
from reversion.admin import VersionAdmin |
|
|
|
from django_reverse_admin import ReverseModelAdmin |
|
|
|
from solo.admin import SingletonModelAdmin |
|
|
|
|
|
|
|
|
|
|
|
# Todo: reversion |
|
|
|
|
|
|
|
import seminar.models as m |
|
|
@ -14,8 +17,6 @@ admin.site.register(m.Skola) |
|
|
|
admin.site.register(m.Prijemce) |
|
|
|
admin.site.register(m.Rocnik) |
|
|
|
admin.site.register(m.Cislo) |
|
|
|
admin.site.register(m.Organizator) |
|
|
|
admin.site.register(m.Soustredeni) |
|
|
|
|
|
|
|
@admin.register(m.Osoba) |
|
|
|
class OsobaAdmin(admin.ModelAdmin): |
|
|
@ -42,7 +43,14 @@ class OsobaAdmin(admin.ModelAdmin): |
|
|
|
org.save() |
|
|
|
udelej_orgem.short_description = "Udělej vybraných osob organizátory" |
|
|
|
|
|
|
|
@admin.register(m.Organizator) |
|
|
|
class OrganizatorAdmin(admin.ModelAdmin): |
|
|
|
search_fields = ['osoba__jmeno', 'osoba__prijmeni', 'prezdivka'] |
|
|
|
|
|
|
|
@admin.register(m.Resitel) |
|
|
|
class ResitelAdmin(admin.ModelAdmin): |
|
|
|
search_fields = ['jmeno', 'prijmeni', 'prezdivka'] |
|
|
|
ordering = ('osoba__jmeno','osoba__prijmeni') |
|
|
|
|
|
|
|
@admin.register(m.Problem) |
|
|
|
class ProblemAdmin(PolymorphicParentModelAdmin): |
|
|
@ -74,15 +82,55 @@ class KonferaAdmin(PolymorphicChildModelAdmin): |
|
|
|
base_model = m.Konfera |
|
|
|
show_in_index = True |
|
|
|
|
|
|
|
|
|
|
|
class TextAdminInline(admin.TabularInline): |
|
|
|
model = m.Text |
|
|
|
formfield_overrides = { |
|
|
|
models.TextField: {'widget': widgets.TextInput} |
|
|
|
} |
|
|
|
exclude = ['text_zkraceny_set','text_zkraceny'] |
|
|
|
|
|
|
|
admin.site.register(m.Text) |
|
|
|
|
|
|
|
class ResitelInline(admin.TabularInline): |
|
|
|
model = m.Resitel |
|
|
|
extra = 1 |
|
|
|
admin.site.register(m.Resitel) |
|
|
|
|
|
|
|
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] |
|
|
|
|
|
|
|
|
|
|
|
class PrilohaReseniInline(admin.TabularInline): |
|
|
|
model = m.PrilohaReseni |
|
|
@ -92,6 +140,7 @@ admin.site.register(m.PrilohaReseni) |
|
|
|
class Reseni_ResiteleInline(admin.TabularInline): |
|
|
|
model = m.Reseni_Resitele |
|
|
|
|
|
|
|
|
|
|
|
@admin.register(m.Reseni) |
|
|
|
class ReseniAdmin(ReverseModelAdmin): |
|
|
|
base_model = m.Reseni |
|
|
@ -106,7 +155,6 @@ admin.site.register(m.Hodnoceni) |
|
|
|
admin.site.register(m.Pohadka) |
|
|
|
admin.site.register(m.Obrazek) |
|
|
|
|
|
|
|
|
|
|
|
# Polymorfismus pro stromy |
|
|
|
# TODO: Inlines podle https://django-polymorphic.readthedocs.io/en/stable/admin.html |
|
|
|
|
|
|
|