hide the switch-shape dropdown when its a saved renkan (id_rk is set)
authorrougeronj
Fri, 06 Mar 2015 17:17:38 +0100
changeset 490 97afeb38e259
parent 489 f2e44ee54f61
child 491 8444b4f67e45
child 507 81acd8021764
hide the switch-shape dropdown when its a saved renkan (id_rk is set)
src/hdalab/templates/renkan_edit.html
src/hdalab/views/profile.py
--- a/src/hdalab/templates/renkan_edit.html	Fri Mar 06 15:34:45 2015 +0100
+++ b/src/hdalab/templates/renkan_edit.html	Fri Mar 06 17:17:38 2015 +0100
@@ -186,6 +186,7 @@
 <div class="all-title">
 	<h1><strong>RENKAN</strong></h1>
 	<div class="renkan_help">
+		{% if switch_shape_url %}
 		<ul>
 			<li>
 				{% trans 'Change organisation' %}
@@ -207,6 +208,7 @@
 				</ul>
 			</li>
 		</ul>
+		{% endif %}
 		<a id="toggle-help" href="#"></a>
 	</div>
 </div>
--- a/src/hdalab/views/profile.py	Fri Mar 06 15:34:45 2015 +0100
+++ b/src/hdalab/views/profile.py	Fri Mar 06 17:17:38 2015 +0100
@@ -166,25 +166,25 @@
             hr = get_object_or_404(HdalabRenkan.objects.select_related("renkan", "renkan__owner"), renkan__rk_id=rk_id) #.get(=rk_id)
             if hr.renkan.owner!=self.request.user or hr.state!=HdalabRenkan.EDITION:
                 raise Exception("You are not allowed to edit this renkan")
-        
+        else:
+            current_url = self.request.get_full_path()
+            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:
+                #if we generated the renkan from no filter, the url doesn't have any "?"
+                #we add one to create the links to the other representation
+                if "?" not in current_url:
+                    current_url += "?"
+                switch_shape_url["horiz"] = current_url + "&shape=horiz"
+                switch_shape_url["vert"] = current_url + "&shape=vert"
+            context["switch_shape_url"] = switch_shape_url
         form = AuthenticationForm(self.request)
         context["form"] = form
-        current_url = self.request.get_full_path()
-        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:
-            #if we generated the renkan from no filter, the url doesn't have any "?"
-            #we add one to create the links to the other representation
-            if "?" not in current_url:
-                current_url += "?"
-            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