Přidán TreeNode.get_admin_url()

This commit is contained in:
Pavel 'LEdoian' Turinsky 2020-05-06 23:13:52 +02:00
parent 39dc2d8e32
commit 730a7dfe5a

View file

@ -14,6 +14,7 @@ from django.utils.text import slugify
from django.urls import reverse
from django.core.cache import cache
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.contenttypes.models import ContentType
from django.utils.text import get_valid_filename
from imagekit.models import ImageSpecField, ProcessedImageField
from imagekit.processors import ResizeToFit, Transpose
@ -1303,6 +1304,10 @@ class TreeNode(PolymorphicModel):
def aktualizuj_nazev(self):
raise NotImplementedError("Pokus o aktualizaci názvu obecného TreeNode místo konkrétní instance")
def get_admin_url(self):
content_type = ContentType.objects.get_for_model(self.__class__)
return reverse("admin:%s_%s_change" % (content_type.app_label, content_type.model), args=(self.id,))
class RocnikNode(TreeNode):
class Meta:
db_table = 'seminar_nodes_rocnik'