tweak topmenu for both logged-in or not-logged-in cases
[myslice.git] / myslice / viewutils.py
index 669c4ca..b9309e1 100644 (file)
@@ -1,24 +1,39 @@
 # a set of utilities to help make the global layout consistent across views
 
-from copy import deepcopy
-
+# this 
 standard_topmenu_items = [ 
-    { 'label':'Tab', 'href': '/tab/'},
-    { 'label':'Scroll', 'href': '/scroll/'},
-    { 'label':'Plugin', 'href': '/plugin/'},
-    { 'label':'Dashboard', 'href': '/dashboard/'},
-    { 'label':'Slice', 'href': '/slice/'},
+#    { 'label':'Tab', 'href': '/tab/'},
+#    { 'label':'Scroll', 'href': '/scroll/'},
+#    { 'label':'One Plugin', 'href': '/plugin/'},
+# Thierry : using this goes to some test slice that not every one is in
+# besides, the topmenu needs to be shrunk down horizontally
+# otherwise the topmenu takes more vertical space than avail. and the layout is broken
+#    { 'label':'Slice', 'href': '/slice/'},
+    #{'label':'My Account', 'href': '/portal/account/'}
     ]
 
 #login_out_items = { False: { 'label':'Login', 'href':'/login/'},
 #                    True:  { 'label':'Logout', 'href':'/logout/'}}
 
 def topmenu_items (current,request=None):
-    result=deepcopy(standard_topmenu_items)
+    has_user=request.user.is_authenticated()
+    result=[]
+    if has_user:
+        result.append({'label':'Platforms', 'href': '/portal/platforms/'})
+        result.append({ 'label':'Dashboard', 'href': '/portal/dashboard/'})
+        # This should probably go in dashboard at some point
+        result.append({ 'label':'Request a slice', 'href': '/portal/slice_request/'})
+        result.append({'label':'My Account', 'href': '/portal/account/'})
+    else:
+        result.append({'label':'Home', 'href': '/login'})
+        # looks like this is accessible to non-logged users
+        result.append({'label':'Platforms', 'href': '/portal/platforms/'})
+        result.append({ 'label':'Register', 'href': '/portal/register/'})
+    result.append({'label':'Contact Support', 'href': '/portal/contact/'})
     for d in result:
-        if d['label'].lower().find(current)>=0: d['active']=True
+        #if d['label'].lower()find(current)>=0: d['is_active']=True
+        if d['label'] == current: d['is_active']=True
     if not request: return result
-    has_user=request.user.is_authenticated()
 #    result.append (login_out_items [ has_user] )
     return result