--- a/server/python/django2/renkanmanager/utils.py Tue Jun 21 10:30:08 2016 +0200
+++ b/server/python/django2/renkanmanager/utils.py Tue Jun 21 17:53:06 2016 +0200
@@ -10,6 +10,7 @@
from django.shortcuts import get_object_or_404
from django.utils.encoding import smart_str
from renkanmanager.models import Renkan
+import distutils
import math
import hashlib
import re
@@ -29,12 +30,12 @@
class NodePlacer():
-
+
cat_nb_nodes = {}
-
+
def init(self, cat_nb_nodes_initial):
raise NotImplementedError( "Should have implemented init" )
-
+
def get_place(self, category):
if not category or category not in self.cat_nb_nodes:
raise Http404
@@ -43,9 +44,9 @@
class LineNodePlacer(NodePlacer): #vertical lines
-
+
max_length = 0
-
+
def init(self, cat_nb_nodes_initial):
for c in cat_nb_nodes_initial:
nb = cat_nb_nodes_initial[c]
@@ -67,9 +68,9 @@
class HorLineNodePlacer(NodePlacer): #horizontal lines
-
+
max_length = 0
-
+
def init(self, cat_nb_nodes_initial):
for c in cat_nb_nodes_initial:
nb = cat_nb_nodes_initial[c]
@@ -93,7 +94,7 @@
self.cat_nb_nodes[c].append({ "x": 100*(i+offset), "y": order*450 })
class CircleNodePlacer(NodePlacer):
-
+
def init(self, cat_nb_nodes_initial):
for i_cat,c in enumerate(cat_nb_nodes_initial):
self.cat_nb_nodes[c] = []
@@ -133,4 +134,8 @@
raise ValidationError("You are not allowed to remove this renkan")
-
+def parse_bool(value):
+ try:
+ return bool(value and distutils.util.strtobool(value.lower()))
+ except ValueError:
+ return False