Commit 34850b9a29a72bd3b8a47bec70daa3bdf3c509ae
1 parent
a621653f
Exists in
master
and in
39 other branches
Add dynamic links
Signed-off-by: Gustavo Jaruga <darksshades@gmail.com> Signed-off-by: Macartur Souza <macartur.sc@gmail.com>
Showing
2 changed files
with
14 additions
and
3 deletions
Show diff stats
colab/proxy/noosfero/apps.py
| ... | ... | @@ -15,7 +15,9 @@ class ProxyNoosferoAppConfig(ColabProxiedAppConfig): |
| 15 | 15 | (_('Communities'), 'search/communities'), |
| 16 | 16 | ), |
| 17 | 17 | 'auth_links': ( |
| 18 | - (_('Profile'), 'profile'), | |
| 19 | - (_('Control panel'), 'myprofile'), | |
| 18 | + (_('Profile'), 'profile/{0}'), | |
| 19 | + (_('Control panel'), 'myprofile/{0}'), | |
| 20 | 20 | ), |
| 21 | 21 | } |
| 22 | + | |
| 23 | + arguments = ["context['user']"] | ... | ... |
colab/proxy/templatetags/proxy.py
| ... | ... | @@ -37,8 +37,17 @@ def proxy_menu(context): |
| 37 | 37 | if title not in menu_links: |
| 38 | 38 | menu_links[title] = [] |
| 39 | 39 | |
| 40 | + is_authenticated = context['request'].user.is_authenticated() | |
| 41 | + if hasattr(app, 'arguments') and is_authenticated: | |
| 42 | + arguments = app.arguments | |
| 43 | + else: | |
| 44 | + arguments = [] | |
| 45 | + | |
| 46 | + for i, _ in enumerate(arguments): | |
| 47 | + arguments[i] = eval(arguments[i]) | |
| 48 | + | |
| 40 | 49 | for text, link in links: |
| 41 | - url = reverse(app.label, args=(link,)) | |
| 50 | + url = reverse(app.label, args=(link.format(*arguments),)) | |
| 42 | 51 | menu_links[title].append((text, url)) |
| 43 | 52 | |
| 44 | 53 | menu = render_to_string('proxy/menu_template.html', | ... | ... |