Commit cb79e2ed authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Improve get_menu view

Allow enabling/disabling some of the menus.
Changed some of the titles.
parent ba24226c
......@@ -116,7 +116,7 @@ def get_services(request):
return HttpResponse(content=data, mimetype=mimetype)
def get_menu(request):
def get_menu(request, with_extra_links=False, with_signout=True):
location = request.GET.get('location', '')
exclude = []
index_url = reverse('index')
......@@ -136,17 +136,19 @@ def get_menu(request):
l.append({ 'url': absolute(reverse('astakos.im.views.index')),
'name': request.user.email})
l.append({ 'url': absolute(reverse('astakos.im.views.edit_profile')),
'name': "View your profile" })
if request.user.password:
l.append({ 'url': absolute(reverse('password_change')),
'name': "Change your password" })
if INVITATIONS_ENABLED:
l.append({ 'url': absolute(reverse('astakos.im.views.invite')),
'name': "Invite some friends" })
l.append({ 'url': absolute(reverse('astakos.im.views.send_feedback')),
'name': "Send feedback" })
l.append({ 'url': absolute(reverse('astakos.im.views.logout')),
'name': "Sign out"})
'name': "My account" })
if with_extra_links:
if request.user.password:
l.append({ 'url': absolute(reverse('password_change')),
'name': "Change password" })
if INVITATIONS_ENABLED:
l.append({ 'url': absolute(reverse('astakos.im.views.invite')),
'name': "Invitations" })
l.append({ 'url': absolute(reverse('astakos.im.views.send_feedback')),
'name': "Feedback" })
if with_signout:
l.append({ 'url': absolute(reverse('astakos.im.views.logout')),
'name': "Sign out"})
callback = request.GET.get('callback', None)
data = json.dumps(tuple(l))
......
......@@ -56,7 +56,7 @@ def media(request):
def menu(request):
absolute = lambda (url): request.build_absolute_uri(url)
resp = get_menu(request)
resp = get_menu(request, True, False)
menu_items = json.loads(resp.content)[1:]
for item in menu_items:
item['is_active'] = absolute(request.path) == item['url']
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment