Browse Source

Přesun kódu modelů treenode

v3
Jonas Havelka 1 year ago
parent
commit
78923f5237
  1. 1
      seminar/models/__init__.py
  2. 2
      seminar/testutils.py
  3. 2
      seminar/utils.py
  4. 2
      treenode/admin.py
  5. 2
      treenode/models.py
  6. 2
      treenode/serializers.py
  7. 2
      treenode/templatetags.py
  8. 2
      treenode/tests.py
  9. 6
      treenode/treelib.py
  10. 2
      treenode/views.py
  11. 2
      treenode/viewsets.py
  12. 6
      tvorba/models.py

1
seminar/models/__init__.py

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

2
seminar/testutils.py

@ -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

2
seminar/utils.py

@ -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

2
treenode/admin.py

@ -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

2
seminar/models/treenode.py → treenode/models.py

@ -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__)

2
treenode/serializers.py

@ -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

2
treenode/templatetags.py

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

2
treenode/tests.py

@ -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):

6
treenode/treelib.py

@ -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):

2
treenode/views.py

@ -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

2
treenode/viewsets.py

@ -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

6
tvorba/models.py

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

Loading…
Cancel
Save