Polymorfičtí admini pro TreeNody
This commit is contained in:
parent
d64214c75d
commit
4ee3d41237
1 changed files with 78 additions and 11 deletions
|
@ -1,5 +1,7 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from polymorphic.admin import PolymorphicParentModelAdmin, PolymorphicChildModelAdmin, PolymorphicChildModelFilter
|
||||
|
||||
import seminar.models as m
|
||||
|
||||
admin.site.register(m.Osoba)
|
||||
|
@ -10,27 +12,92 @@ admin.site.register(m.Rocnik)
|
|||
admin.site.register(m.Cislo)
|
||||
admin.site.register(m.Organizator)
|
||||
admin.site.register(m.Soustredeni)
|
||||
|
||||
# TODO: Polymorphic admin
|
||||
admin.site.register(m.Problem)
|
||||
admin.site.register(m.Tema)
|
||||
admin.site.register(m.Clanek)
|
||||
admin.site.register(m.Text)
|
||||
admin.site.register(m.Uloha)
|
||||
# END TODO.
|
||||
|
||||
admin.site.register(m.Reseni)
|
||||
admin.site.register(m.Hodnoceni)
|
||||
admin.site.register(m.PrilohaReseni)
|
||||
admin.site.register(m.Pohadka)
|
||||
admin.site.register(m.Konfera)
|
||||
admin.site.register(m.Obrazek)
|
||||
admin.site.register(m.TreeNode)
|
||||
admin.site.register(m.RocnikNode)
|
||||
admin.site.register(m.CisloNode)
|
||||
admin.site.register(m.MezicisloNode)
|
||||
admin.site.register(m.TemaVCisleNode)
|
||||
admin.site.register(m.KonferaNode)
|
||||
admin.site.register(m.ClanekNode)
|
||||
admin.site.register(m.UlohaZadaniNode)
|
||||
admin.site.register(m.PohadkaNode)
|
||||
admin.site.register(m.UlohaVzorakNode)
|
||||
admin.site.register(m.TextNode)
|
||||
|
||||
|
||||
# Polymorfismus pro stromy
|
||||
# TODO: Inlines podle https://django-polymorphic.readthedocs.io/en/stable/admin.html
|
||||
|
||||
@admin.register(m.TreeNode)
|
||||
class TreeNodeAdmin(PolymorphicParentModelAdmin):
|
||||
base_model = m.TreeNode
|
||||
child_models = [
|
||||
m.RocnikNode,
|
||||
m.CisloNode,
|
||||
m.MezicisloNode,
|
||||
m.TemaVCisleNode,
|
||||
m.KonferaNode,
|
||||
m.ClanekNode,
|
||||
m.UlohaZadaniNode,
|
||||
m.PohadkaNode,
|
||||
m.UlohaVzorakNode,
|
||||
m.TextNode,
|
||||
]
|
||||
|
||||
@admin.register(m.RocnikNode)
|
||||
class RocnikNodeAdmin(PolymorphicChildModelAdmin):
|
||||
base_model = m.RocnikNode
|
||||
show_in_index = True
|
||||
|
||||
@admin.register(m.CisloNode)
|
||||
class CisloNodeAdmin(PolymorphicChildModelAdmin):
|
||||
base_model = m.CisloNode
|
||||
show_in_index = True
|
||||
|
||||
@admin.register(m.MezicisloNode)
|
||||
class MezicisloNodeAdmin(PolymorphicChildModelAdmin):
|
||||
base_model = m.MezicisloNode
|
||||
show_in_index = True
|
||||
|
||||
@admin.register(m.TemaVCisleNode)
|
||||
class TemaVCisleNodeAdmin(PolymorphicChildModelAdmin):
|
||||
base_model = m.TemaVCisleNode
|
||||
show_in_index = True
|
||||
|
||||
@admin.register(m.KonferaNode)
|
||||
class KonferaNodeAdmin(PolymorphicChildModelAdmin):
|
||||
base_model = m.KonferaNode
|
||||
show_in_index = True
|
||||
|
||||
@admin.register(m.ClanekNode)
|
||||
class ClanekNodeAdmin(PolymorphicChildModelAdmin):
|
||||
base_model = m.ClanekNode
|
||||
show_in_index = True
|
||||
|
||||
@admin.register(m.UlohaZadaniNode)
|
||||
class UlohaZadaniNodeAdmin(PolymorphicChildModelAdmin):
|
||||
base_model = m.UlohaZadaniNode
|
||||
show_in_index = True
|
||||
|
||||
@admin.register(m.PohadkaNode)
|
||||
class PohadkaNodeAdmin(PolymorphicChildModelAdmin):
|
||||
base_model = m.PohadkaNode
|
||||
show_in_index = True
|
||||
|
||||
@admin.register(m.UlohaVzorakNode)
|
||||
class UlohaVzorakNodeAdmin(PolymorphicChildModelAdmin):
|
||||
base_model = m.UlohaVzorakNode
|
||||
show_in_index = True
|
||||
|
||||
@admin.register(m.TextNode)
|
||||
class TextNodeAdmin(PolymorphicChildModelAdmin):
|
||||
base_model = m.TextNode
|
||||
show_in_index = True
|
||||
|
||||
|
||||
admin.site.register(m.Nastaveni)
|
||||
admin.site.register(m.Novinky)
|
||||
|
|
Loading…
Reference in a new issue