Přesun kódu modelů treenode

This commit is contained in:
Jonas Havelka 2023-08-10 09:12:23 +02:00
parent 0fd3526a87
commit 78923f5237
12 changed files with 15 additions and 16 deletions

View file

@ -1,4 +1,3 @@
from .base import *
from .pomocne import *
from .treenode import *
from .novinky import *

View file

@ -19,7 +19,7 @@ from odevzdavatko.models import *
from soustredeni.models import *
from seminar.models.novinky 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.sites.models import Site

View file

@ -18,7 +18,7 @@ import logging
from personalni.models import Organizator, Resitel, Skola, Prijemce
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 odevzdavatko.models import Reseni_Resitele
import treenode.treelib as t

View file

@ -2,7 +2,7 @@ from django.contrib import admin
from polymorphic.admin import PolymorphicParentModelAdmin, PolymorphicChildModelAdmin, PolymorphicChildModelFilter
from seminar.models.treenode import *
from .models import *
# Polymorfismus pro stromy
# TODO: Inlines podle https://django-polymorphic.readthedocs.io/en/stable/admin.html

View file

@ -11,7 +11,7 @@ from polymorphic.models import PolymorphicModel
from odevzdavatko.models import Reseni
from personalni.models import Organizator
from .pomocne import Text
from seminar.models.pomocne import Text
logger = logging.getLogger(__name__)

View file

@ -1,7 +1,7 @@
from rest_framework import serializers
from rest_polymorphic.serializers import PolymorphicSerializer
from seminar.models.treenode import *
from .models import *
from seminar.models.pomocne import Text
from odevzdavatko.models import Reseni
from tvorba.models import Problem, Uloha

View file

@ -1,6 +1,6 @@
from django import template
from enum import Enum
from seminar.models.treenode import *
from .models import *
register = template.Library()

View file

@ -1,6 +1,6 @@
from django.test import TestCase
import treenode.treelib as tl
from seminar.models.treenode import *
from .models import *
class SimpleTreeLibTests(TestCase):
def setUp(self):

View file

@ -238,7 +238,7 @@ class TreeLibError(RuntimeError):
# Editace stromu:
def create_node_after(predecessor, type, **kwargs):
from seminar.models.treenode import TreeNode
from .models import TreeNode
if predecessor is None:
raise TreeLibError("Nelze vyrábět sirotky! (predecessor=None)")
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)
def create_child(parent, type, **kwargs):
from seminar.models.treenode import TreeNode
from .models import TreeNode
if parent is None:
raise TreeLibError("Nelze vyrábět sirotky! (parent=None)")
if not issubclass(type, TreeNode):
@ -293,7 +293,7 @@ def insert_last_child(parent, node):
last.save()
def create_node_before(successor, type, **kwargs):
from seminar.models.treenode import TreeNode
from .models import TreeNode
if successor is None:
raise TreeLibError("Nelze vyrábět sirotky! (successor=None)")
if not issubclass(type, TreeNode):

View file

@ -6,7 +6,7 @@ from django.views.generic.edit import CreateView
from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.exceptions import PermissionDenied
from seminar.models.treenode import *
from .models import *
from seminar.models.pomocne import Text, Obrazek
from treenode import treelib
import treenode.forms as f

View file

@ -3,7 +3,7 @@ from rest_framework import status
from rest_framework.response import Response
from django.core.exceptions import PermissionDenied
from rest_framework.permissions import BasePermission, AllowAny
from seminar.models.treenode import *
from .models import *
from tvorba.models import Problem, Uloha
from odevzdavatko.models import Reseni
import treenode.serializers as views

View file

@ -319,7 +319,7 @@ class Cislo(SeminarModelBase):
except ObjectDoesNotExist:
# Neexistující *Node nemá smysl aktualizovat, ale je potřeba ho naopak vyrobit
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)
def zlomovy_deadline_pro_papirove_cislo(self):
@ -583,7 +583,7 @@ class Tema(Problem):
def cislo_node(self):
tema_node_set = self.temavcislenode_set.all()
tema_cisla_vyskyt = []
from seminar.models.treenode import CisloNode
from treenode.models import CisloNode
for tn in tema_node_set:
tema_cisla_vyskyt.append(
treelib.get_upper_node_of_type(tn, CisloNode).cislo)
@ -664,7 +664,7 @@ class Uloha(Problem):
def cislo_node(self):
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)