Add horizontal line representation
authorrougeronj
Mon, 05 Jan 2015 17:38:36 +0100
changeset 420 9788eced982a
parent 419 469ad9ef43e5
child 421 2eee6f61f1c6
Add horizontal line representation
src/hdalab/static/hdalab/css/renkan_help.css
src/hdalab/templates/renkan_edit.html
src/hdalab/views/profile.py
--- a/src/hdalab/static/hdalab/css/renkan_help.css	Mon Jan 05 15:46:20 2015 +0100
+++ b/src/hdalab/static/hdalab/css/renkan_help.css	Mon Jan 05 17:38:36 2015 +0100
@@ -71,6 +71,9 @@
 #graph-line {
 	background: url("../img/graph-line.png") no-repeat scroll  right 5px center / 25px 25px #ffffff;
 }
+#graph-lineH {
+	background: url("../img/graph-lineH.png") no-repeat scroll  right 5px center / 25px 25px #ffffff;
+}
 #graph-line:hover a,
 #graph-circle:hover a{
 	color: #4f5451;
--- a/src/hdalab/templates/renkan_edit.html	Mon Jan 05 15:46:20 2015 +0100
+++ b/src/hdalab/templates/renkan_edit.html	Mon Jan 05 17:38:36 2015 +0100
@@ -185,11 +185,17 @@
 				{% trans 'Changer de disposition' %}
 				<p> {% trans '(Indisponible si modification du RENKAN)' %}</p>
 				<ul>
-					{% if 'shape=circle' in switch_shape_url %}
-						<li id="graph-line"><a href="">&#10003&nbsp;{% trans 'See the graph in line' %}</a></li>
-						<li id="graph-circle"><a href="{{ switch_shape_url }}">&nbsp;&nbsp;&nbsp;{% trans 'See the graph in circle' %}</a></li>
+					{% if 'shape=vert' in switch_shape_url.current %}
+						<li id="graph-line"><a href="">&#10003&nbsp;{% trans 'See the graph in column' %}</a></li>
+						<li id="graph-lineH"><a href="{{ switch_shape_url.horiz }}">&nbsp;&nbsp;&nbsp;{% trans 'See the graph in line' %}</a></li>
+						<li id="graph-circle"><a href="{{ switch_shape_url.circle }}">&nbsp;&nbsp;&nbsp;{% trans 'See the graph in circle' %}</a></li>
+					{% elif 'shape=horiz' in switch_shape_url.current %}
+						<li id="graph-line"><a href="{{ switch_shape_url.vert }}">&nbsp;&nbsp;&nbsp;{% trans 'See the graph in column' %}</a></li>
+						<li id="graph-lineH"><a href="">&#10003&nbsp;{% trans 'See the graph in line' %}</a></li>
+						<li id="graph-circle"><a href="{{ switch_shape_url.circle }}">&nbsp;&nbsp;&nbsp;{% trans 'See the graph in circle' %}</a></li>
 					{% else %}
-						<li id="graph-line"><a href="{{ switch_shape_url }}">&nbsp;&nbsp;&nbsp;{% trans 'See the graph in line' %}</a></li>
+						<li id="graph-line"><a href="{{ switch_shape_url.vert }}">&nbsp;&nbsp;&nbsp;{% trans 'See the graph in column' %}</a></li>
+						<li id="graph-lineH"><a href="{{ switch_shape_url.horiz }}">&nbsp;&nbsp;&nbsp;{% trans 'See the graph in line' %}</a></li>
 						<li id="graph-circle"><a href="">&#10003&nbsp;{% trans 'See the graph in circle' %}</a></li>
 					{% endif %}
 				</ul>
--- a/src/hdalab/views/profile.py	Mon Jan 05 15:46:20 2015 +0100
+++ b/src/hdalab/views/profile.py	Mon Jan 05 17:38:36 2015 +0100
@@ -31,7 +31,7 @@
 from hdalab.models.renkan import HdalabRenkan
 from hdalab.views.ajax import filter_generic
 from renkanmanager.models import Renkan
-from renkanmanager.utils import LineNodePlacer, renkan_copier, renkan_deleter,\
+from renkanmanager.utils import LineNodePlacer, HorLineNodePlacer, renkan_copier, renkan_deleter,\
     CircleNodePlacer
 from renkanmanager.views import RenkanGetPut
 import json
@@ -142,6 +142,7 @@
     template_name="renkan_edit.html"
     
     def get_context_data(self, **kwargs):
+        switch_shape_url= {}
         context = super(RenkanEdit, self).get_context_data(**kwargs)
         # If a renkan id is set
         rk_id = self.request.GET.get("rk_id", "")
@@ -153,10 +154,16 @@
         form = AuthenticationForm(self.request)
         context["form"] = form
         current_url = self.request.get_full_path()
-        if "shape=circle" in current_url:
-            switch_shape_url = current_url.replace("&shape=circle", "")
+        switch_shape_url["current"] = current_url
+        if "shape=horiz" in current_url:
+            switch_shape_url["vert"] = current_url.replace("&shape=horiz", "&shape=vert")
+            switch_shape_url["circle"] = current_url.replace("&shape=horiz", "")
+        elif "shape=vert" in current_url:
+            switch_shape_url["horiz"] = current_url.replace("&shape=vert", "&shape=horiz")
+            switch_shape_url["circle"] = current_url.replace("&shape=vert", "")
         else:
-            switch_shape_url = current_url + "&shape=circle"
+            switch_shape_url["horiz"] = current_url + "&shape=horiz"
+            switch_shape_url["vert"] = current_url + "&shape=vert"
         context["switch_shape_url"] = switch_shape_url
         
         return context
@@ -218,9 +225,12 @@
             # We get the ORDERED tags if we display one sheet
             ordered_tags = TaggedSheet.objects.filter(datasheet=notice).select_related("tag", "tag__dbpedia_fields", "tag__category").order_by('order')[:15]
             # Prepare Node placer :
-            np = LineNodePlacer()
-            if shape=="circle":
-                np = CircleNodePlacer()
+            np = CircleNodePlacer()
+            if shape=="horiz":
+                np = HorLineNodePlacer()
+            elif shape=="vert":
+                np = LineNodePlacer()
+                
             np.init({"datasheet": (1, 1), "tags": (2, len(ordered_tags))})
             # Place notice :
             content["nodes"].append({