Browse Source

Přesun ReseniNode do treenode

v3
Jonas Havelka 1 year ago
parent
commit
8c881621b0
  1. 17
      seminar/models/odevzdavatko.py
  2. 18
      seminar/models/treenode.py
  3. 2
      treenode/serializers.py
  4. 1
      treenode/views.py
  5. 2
      treenode/viewsets.py

17
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)

18
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)

2
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

1
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

2
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

Loading…
Cancel
Save