1 # a set of utilities to help make the global layout consistent across views
3 # dropdowns are kind of ad hoc for now, and limited to one level
5 # ### a regular first-level button
6 # {'label':...,'href':...},
8 # { 'label': ..., 'href'=..., 'dropdown':True, 'contents': [ { 'label':.., 'href'} ] }
10 def topmenu_items (current,request=None):
11 has_user=request.user.is_authenticated()
14 result.append({'label':'Dashboard', 'href': '/portal/dashboard/'})
15 result.append({'label':'Request a slice', 'href': '/portal/slice_request/'})
16 result.append({'label':'My Account', 'href': '/portal/account/'})
17 result.append({'label':'Contact Support', 'href': '/portal/contact/'})
18 # Not really useful at this point, is it ?
19 # This should probably go into dashboard at some point
20 # result.append({'label':'Platforms', 'href': '/portal/platforms/'})
21 # the code for building a dropdown instead - but somehow this is broken
22 # dropdown = [ {'label':'..', 'href': '..'}, ...]
23 # result.append({'label': 'More', 'href':"#", 'dropdown':True, 'contents':dropdown})
25 result.append({'label':'Home', 'href': '/login'})
26 # looks like this is accessible to non-logged users
27 result.append({'label':'Platforms', 'href': '/portal/platforms/'})
28 result.append({'label':'Register', 'href': '/portal/register/'})
29 result.append({'label':'Contact Support', 'href': '/portal/contact/'})
33 for dd in d['contents']:
34 if dd['label'] == current: dd['is_active']=True
36 if d['label'] == current: d['is_active']=True
39 def the_user (request):
40 "retrieves logged in user's email, or empty string"
41 if not request.user.is_authenticated ():
44 return request.user.email