Přesun kódu modelů treenode
This commit is contained in:
parent
0fd3526a87
commit
78923f5237
12 changed files with 15 additions and 16 deletions
|
@ -1,4 +1,3 @@
|
||||||
from .base import *
|
from .base import *
|
||||||
from .pomocne import *
|
from .pomocne import *
|
||||||
from .treenode import *
|
|
||||||
from .novinky import *
|
from .novinky import *
|
||||||
|
|
|
@ -19,7 +19,7 @@ from odevzdavatko.models import *
|
||||||
from soustredeni.models import *
|
from soustredeni.models import *
|
||||||
from seminar.models.novinky import *
|
from seminar.models.novinky import *
|
||||||
from seminar.models.pomocne import *
|
from seminar.models.pomocne import *
|
||||||
from seminar.models.treenode import *
|
from treenode.models import *
|
||||||
|
|
||||||
from django.contrib.flatpages.models import FlatPage
|
from django.contrib.flatpages.models import FlatPage
|
||||||
from django.contrib.sites.models import Site
|
from django.contrib.sites.models import Site
|
||||||
|
|
|
@ -18,7 +18,7 @@ import logging
|
||||||
|
|
||||||
from personalni.models import Organizator, Resitel, Skola, Prijemce
|
from personalni.models import Organizator, Resitel, Skola, Prijemce
|
||||||
from tvorba.models import Clanek, Rocnik
|
from tvorba.models import Clanek, Rocnik
|
||||||
from seminar.models.treenode import CisloNode
|
from treenode.models import CisloNode
|
||||||
from soustredeni.models import Konfery_Ucastnici, Soustredeni_Ucastnici
|
from soustredeni.models import Konfery_Ucastnici, Soustredeni_Ucastnici
|
||||||
from odevzdavatko.models import Reseni_Resitele
|
from odevzdavatko.models import Reseni_Resitele
|
||||||
import treenode.treelib as t
|
import treenode.treelib as t
|
||||||
|
|
|
@ -2,7 +2,7 @@ from django.contrib import admin
|
||||||
|
|
||||||
from polymorphic.admin import PolymorphicParentModelAdmin, PolymorphicChildModelAdmin, PolymorphicChildModelFilter
|
from polymorphic.admin import PolymorphicParentModelAdmin, PolymorphicChildModelAdmin, PolymorphicChildModelFilter
|
||||||
|
|
||||||
from seminar.models.treenode import *
|
from .models import *
|
||||||
|
|
||||||
# Polymorfismus pro stromy
|
# Polymorfismus pro stromy
|
||||||
# TODO: Inlines podle https://django-polymorphic.readthedocs.io/en/stable/admin.html
|
# TODO: Inlines podle https://django-polymorphic.readthedocs.io/en/stable/admin.html
|
||||||
|
|
|
@ -11,7 +11,7 @@ from polymorphic.models import PolymorphicModel
|
||||||
from odevzdavatko.models import Reseni
|
from odevzdavatko.models import Reseni
|
||||||
from personalni.models import Organizator
|
from personalni.models import Organizator
|
||||||
|
|
||||||
from .pomocne import Text
|
from seminar.models.pomocne import Text
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_polymorphic.serializers import PolymorphicSerializer
|
from rest_polymorphic.serializers import PolymorphicSerializer
|
||||||
|
|
||||||
from seminar.models.treenode import *
|
from .models import *
|
||||||
from seminar.models.pomocne import Text
|
from seminar.models.pomocne import Text
|
||||||
from odevzdavatko.models import Reseni
|
from odevzdavatko.models import Reseni
|
||||||
from tvorba.models import Problem, Uloha
|
from tvorba.models import Problem, Uloha
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django import template
|
from django import template
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from seminar.models.treenode import *
|
from .models import *
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
import treenode.treelib as tl
|
import treenode.treelib as tl
|
||||||
from seminar.models.treenode import *
|
from .models import *
|
||||||
|
|
||||||
class SimpleTreeLibTests(TestCase):
|
class SimpleTreeLibTests(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
|
@ -238,7 +238,7 @@ class TreeLibError(RuntimeError):
|
||||||
|
|
||||||
# Editace stromu:
|
# Editace stromu:
|
||||||
def create_node_after(predecessor, type, **kwargs):
|
def create_node_after(predecessor, type, **kwargs):
|
||||||
from seminar.models.treenode import TreeNode
|
from .models import TreeNode
|
||||||
if predecessor is None:
|
if predecessor is None:
|
||||||
raise TreeLibError("Nelze vyrábět sirotky! (predecessor=None)")
|
raise TreeLibError("Nelze vyrábět sirotky! (predecessor=None)")
|
||||||
if not issubclass(type, TreeNode):
|
if not issubclass(type, TreeNode):
|
||||||
|
@ -255,7 +255,7 @@ def create_node_after(predecessor, type, **kwargs):
|
||||||
|
|
||||||
# Vyrábí prvního syna, ostatní nalepí za (existují-li)
|
# Vyrábí prvního syna, ostatní nalepí za (existují-li)
|
||||||
def create_child(parent, type, **kwargs):
|
def create_child(parent, type, **kwargs):
|
||||||
from seminar.models.treenode import TreeNode
|
from .models import TreeNode
|
||||||
if parent is None:
|
if parent is None:
|
||||||
raise TreeLibError("Nelze vyrábět sirotky! (parent=None)")
|
raise TreeLibError("Nelze vyrábět sirotky! (parent=None)")
|
||||||
if not issubclass(type, TreeNode):
|
if not issubclass(type, TreeNode):
|
||||||
|
@ -293,7 +293,7 @@ def insert_last_child(parent, node):
|
||||||
last.save()
|
last.save()
|
||||||
|
|
||||||
def create_node_before(successor, type, **kwargs):
|
def create_node_before(successor, type, **kwargs):
|
||||||
from seminar.models.treenode import TreeNode
|
from .models import TreeNode
|
||||||
if successor is None:
|
if successor is None:
|
||||||
raise TreeLibError("Nelze vyrábět sirotky! (successor=None)")
|
raise TreeLibError("Nelze vyrábět sirotky! (successor=None)")
|
||||||
if not issubclass(type, TreeNode):
|
if not issubclass(type, TreeNode):
|
||||||
|
|
|
@ -6,7 +6,7 @@ from django.views.generic.edit import CreateView
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
|
|
||||||
from seminar.models.treenode import *
|
from .models import *
|
||||||
from seminar.models.pomocne import Text, Obrazek
|
from seminar.models.pomocne import Text, Obrazek
|
||||||
from treenode import treelib
|
from treenode import treelib
|
||||||
import treenode.forms as f
|
import treenode.forms as f
|
||||||
|
|
|
@ -3,7 +3,7 @@ from rest_framework import status
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from rest_framework.permissions import BasePermission, AllowAny
|
from rest_framework.permissions import BasePermission, AllowAny
|
||||||
from seminar.models.treenode import *
|
from .models import *
|
||||||
from tvorba.models import Problem, Uloha
|
from tvorba.models import Problem, Uloha
|
||||||
from odevzdavatko.models import Reseni
|
from odevzdavatko.models import Reseni
|
||||||
import treenode.serializers as views
|
import treenode.serializers as views
|
||||||
|
|
|
@ -319,7 +319,7 @@ class Cislo(SeminarModelBase):
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
# Neexistující *Node nemá smysl aktualizovat, ale je potřeba ho naopak vyrobit
|
# Neexistující *Node nemá smysl aktualizovat, ale je potřeba ho naopak vyrobit
|
||||||
logger.warning(f'Číslo {self} nemělo ČísloNode, vyrábím…')
|
logger.warning(f'Číslo {self} nemělo ČísloNode, vyrábím…')
|
||||||
from seminar.models.treenode import CisloNode
|
from treenode.models import CisloNode
|
||||||
CisloNode.objects.create(cislo=self)
|
CisloNode.objects.create(cislo=self)
|
||||||
|
|
||||||
def zlomovy_deadline_pro_papirove_cislo(self):
|
def zlomovy_deadline_pro_papirove_cislo(self):
|
||||||
|
@ -583,7 +583,7 @@ class Tema(Problem):
|
||||||
def cislo_node(self):
|
def cislo_node(self):
|
||||||
tema_node_set = self.temavcislenode_set.all()
|
tema_node_set = self.temavcislenode_set.all()
|
||||||
tema_cisla_vyskyt = []
|
tema_cisla_vyskyt = []
|
||||||
from seminar.models.treenode import CisloNode
|
from treenode.models import CisloNode
|
||||||
for tn in tema_node_set:
|
for tn in tema_node_set:
|
||||||
tema_cisla_vyskyt.append(
|
tema_cisla_vyskyt.append(
|
||||||
treelib.get_upper_node_of_type(tn, CisloNode).cislo)
|
treelib.get_upper_node_of_type(tn, CisloNode).cislo)
|
||||||
|
@ -664,7 +664,7 @@ class Uloha(Problem):
|
||||||
|
|
||||||
def cislo_node(self):
|
def cislo_node(self):
|
||||||
zadani_node = self.ulohazadaninode
|
zadani_node = self.ulohazadaninode
|
||||||
from seminar.models.treenode import CisloNode
|
from treenode.models import CisloNode
|
||||||
return treelib.get_upper_node_of_type(zadani_node, CisloNode)
|
return treelib.get_upper_node_of_type(zadani_node, CisloNode)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue