|
|
|
from django.contrib import admin
|
|
|
|
|
|
|
|
from polymorphic.admin import PolymorphicParentModelAdmin, PolymorphicChildModelAdmin, PolymorphicChildModelFilter
|
|
|
|
|
|
|
|
from .models import *
|
|
|
|
|
|
|
|
# Polymorfismus pro stromy
|
|
|
|
# TODO: Inlines podle https://django-polymorphic.readthedocs.io/en/stable/admin.html
|
|
|
|
|
|
|
|
@admin.register(TreeNode)
|
|
|
|
class TreeNodeAdmin(PolymorphicParentModelAdmin):
|
|
|
|
base_model = TreeNode
|
|
|
|
child_models = [
|
|
|
|
RocnikNode,
|
|
|
|
CisloNode,
|
|
|
|
MezicisloNode,
|
|
|
|
TemaVCisleNode,
|
|
|
|
UlohaZadaniNode,
|
|
|
|
PohadkaNode,
|
|
|
|
UlohaVzorakNode,
|
|
|
|
TextNode,
|
|
|
|
CastNode,
|
|
|
|
OrgTextNode,
|
|
|
|
]
|
|
|
|
|
|
|
|
actions = ['aktualizuj_nazvy']
|
|
|
|
|
|
|
|
# XXX: nejspíš je to totální DB HOG, nechcete to použít moc často.
|
|
|
|
def aktualizuj_nazvy(self, request, queryset):
|
|
|
|
newqs = queryset.get_real_instances()
|
|
|
|
for tn in newqs:
|
|
|
|
tn.aktualizuj_nazev()
|
|
|
|
tn.save()
|
|
|
|
self.message_user(request, "Názvy aktualizovány.")
|
|
|
|
aktualizuj_nazvy.short_description = "Aktualizuj vybraným TreeNodům názvy"
|
|
|
|
|
|
|
|
@admin.register(RocnikNode)
|
|
|
|
class RocnikNodeAdmin(PolymorphicChildModelAdmin):
|
|
|
|
base_model = RocnikNode
|
|
|
|
show_in_index = True
|
|
|
|
|
|
|
|
@admin.register(CisloNode)
|
|
|
|
class CisloNodeAdmin(PolymorphicChildModelAdmin):
|
|
|
|
base_model = CisloNode
|
|
|
|
show_in_index = True
|
|
|
|
|
|
|
|
@admin.register(MezicisloNode)
|
|
|
|
class MezicisloNodeAdmin(PolymorphicChildModelAdmin):
|
|
|
|
base_model = MezicisloNode
|
|
|
|
show_in_index = True
|
|
|
|
|
|
|
|
@admin.register(TemaVCisleNode)
|
|
|
|
class TemaVCisleNodeAdmin(PolymorphicChildModelAdmin):
|
|
|
|
base_model = TemaVCisleNode
|
|
|
|
show_in_index = True
|
|
|
|
|
|
|
|
@admin.register(UlohaZadaniNode)
|
|
|
|
class UlohaZadaniNodeAdmin(PolymorphicChildModelAdmin):
|
|
|
|
base_model = UlohaZadaniNode
|
|
|
|
show_in_index = True
|
|
|
|
|
|
|
|
@admin.register(PohadkaNode)
|
|
|
|
class PohadkaNodeAdmin(PolymorphicChildModelAdmin):
|
|
|
|
base_model = PohadkaNode
|
|
|
|
show_in_index = True
|
|
|
|
|
|
|
|
@admin.register(UlohaVzorakNode)
|
|
|
|
class UlohaVzorakNodeAdmin(PolymorphicChildModelAdmin):
|
|
|
|
base_model = UlohaVzorakNode
|
|
|
|
show_in_index = True
|
|
|
|
|
|
|
|
@admin.register(TextNode)
|
|
|
|
class TextNodeAdmin(PolymorphicChildModelAdmin):
|
|
|
|
base_model = TextNode
|
|
|
|
show_in_index = True
|
|
|
|
|
|
|
|
@admin.register(CastNode)
|
|
|
|
class TextNodeAdmin(PolymorphicChildModelAdmin):
|
|
|
|
base_model = CastNode
|
|
|
|
show_in_index = True
|
|
|
|
fields = ('nadpis',)
|
|
|
|
|
|
|
|
@admin.register(OrgTextNode)
|
|
|
|
class TextNodeAdmin(PolymorphicChildModelAdmin):
|
|
|
|
base_model = OrgTextNode
|
|
|
|
show_in_index = True
|
|
|
|
|
|
|
|
|