From 8c881621b00ded7dd0cdfa2b855cca872d49f38a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Mon, 31 Jul 2023 19:31:23 +0200 Subject: [PATCH] =?UTF-8?q?P=C5=99esun=20ReseniNode=20do=20treenode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/models/odevzdavatko.py | 17 ----------------- seminar/models/treenode.py | 18 +++++++++++++++++- treenode/serializers.py | 2 +- treenode/views.py | 1 - treenode/viewsets.py | 2 +- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/seminar/models/odevzdavatko.py b/seminar/models/odevzdavatko.py index d4114b07..083e4f5b 100644 --- a/seminar/models/odevzdavatko.py +++ b/seminar/models/odevzdavatko.py @@ -11,7 +11,6 @@ from django.conf import settings from seminar.models.tvorba import Cislo, Deadline, Problem, Uloha, aux_generate_filename from seminar.models.personalni import Resitel -from seminar.models.treenode import TreeNode from seminar.models.base import SeminarModelBase @@ -242,19 +241,3 @@ class Reseni_Resitele(models.Model): def __str__(self): return '{} od {}'.format(self.reseni, self.resitel) # NOTE: Poteciální DB HOG bez select_related - -class ReseniNode(TreeNode): - class Meta: - db_table = 'seminar_nodes_otistene_reseni' - verbose_name = 'Otištěné řešení (Node)' - verbose_name_plural = 'Otištěná řešení (Node)' - reseni = models.ForeignKey(Reseni, - on_delete=models.PROTECT, - verbose_name = 'reseni') - - def aktualizuj_nazev(self): - self.nazev = "ReseniNode: "+str(self.reseni) - - def getOdkazStr(self): - return str(self.reseni) - diff --git a/seminar/models/treenode.py b/seminar/models/treenode.py index 2ec28fe0..0dd69c06 100644 --- a/seminar/models/treenode.py +++ b/seminar/models/treenode.py @@ -8,7 +8,7 @@ from unidecode import unidecode # Používám pro získání ID odkazu (ještě from polymorphic.models import PolymorphicModel -from . import personalni as pm +from . import personalni as pm, Reseni from .pomocne import Text @@ -263,3 +263,19 @@ class CastNode(TreeNode): def getOdkazStr(self): return str(self.nadpis) + + +class ReseniNode(TreeNode): + class Meta: + db_table = 'seminar_nodes_otistene_reseni' + verbose_name = 'Otištěné řešení (Node)' + verbose_name_plural = 'Otištěná řešení (Node)' + reseni = models.ForeignKey(Reseni, + on_delete=models.PROTECT, + verbose_name = 'reseni') + + def aktualizuj_nazev(self): + self.nazev = "ReseniNode: "+str(self.reseni) + + def getOdkazStr(self): + return str(self.reseni) diff --git a/treenode/serializers.py b/treenode/serializers.py index d2364046..27a8ac82 100644 --- a/treenode/serializers.py +++ b/treenode/serializers.py @@ -3,7 +3,7 @@ from rest_polymorphic.serializers import PolymorphicSerializer from seminar.models.treenode import * from seminar.models.pomocne import Text -from seminar.models.odevzdavatko import Reseni, ReseniNode +from seminar.models.odevzdavatko import Reseni from seminar.models.tvorba import Problem, Uloha from treenode import treelib diff --git a/treenode/views.py b/treenode/views.py index 81577294..8d34d382 100644 --- a/treenode/views.py +++ b/treenode/views.py @@ -8,7 +8,6 @@ from django.core.exceptions import PermissionDenied from seminar.models.treenode import * from seminar.models.pomocne import Text, Obrazek -from seminar.models.odevzdavatko import ReseniNode from treenode import treelib import treenode.forms as f import treenode.templatetags as tnltt diff --git a/treenode/viewsets.py b/treenode/viewsets.py index 3d71d083..7816efbe 100644 --- a/treenode/viewsets.py +++ b/treenode/viewsets.py @@ -5,7 +5,7 @@ from django.core.exceptions import PermissionDenied from rest_framework.permissions import BasePermission, AllowAny from seminar.models.treenode import * from seminar.models.tvorba import Problem, Uloha -from seminar.models.odevzdavatko import Reseni, ReseniNode +from seminar.models.odevzdavatko import Reseni import treenode.serializers as views from treenode.permissions import AllowWrite