Commit 3c88b19834d645f478f7d3ef46fcb3f249a1a653
1 parent
919d26d9
Exists in
master
and in
34 other branches
Add custom menu to configuration
Signed-off-by: Gustavo Jaruga <darksshades@gmail.com> Signed-off-by: Alexandre Barbosa <alexandreab@live.com>
Showing
4 changed files
with
16 additions
and
16 deletions
Show diff stats
colab/plugins/urls.py
| ... | ... | @@ -17,5 +17,5 @@ for app_name, app in settings.COLAB_APPS.items(): |
| 17 | 17 | raise ImproperlyConfigured(undef_url_include_msg) |
| 18 | 18 | urlpatterns += patterns('', |
| 19 | 19 | url(urls.get('prefix', r''), include(urls['include'], |
| 20 | - namespace=urls.get('namespace'))), | |
| 20 | + namespace=urls.get('namespace')), name=app_name), | |
| 21 | 21 | ) | ... | ... |
colab/proxy/context_processors.py
| 1 | 1 | |
| 2 | 2 | from django.apps import apps |
| 3 | +from django.conf import settings | |
| 3 | 4 | |
| 4 | 5 | |
| 5 | 6 | def proxied_apps(request): |
| 6 | 7 | proxied_apps = {} |
| 7 | 8 | |
| 8 | - for app in apps.get_app_configs(): | |
| 9 | - if getattr(app, 'colab_proxied_app', False): | |
| 10 | - proxied_apps[app.label] = app | |
| 9 | + for app_name, app in settings.COLAB_APPS.items(): | |
| 10 | + proxied_apps[app_name] = app | |
| 11 | 11 | |
| 12 | 12 | return {'proxy': proxied_apps} | ... | ... |
colab/proxy/templatetags/proxy.py
| ... | ... | @@ -22,14 +22,16 @@ def proxy_menu(context): |
| 22 | 22 | menu_links = {} |
| 23 | 23 | proxied_apps = context.get('proxy', {}) |
| 24 | 24 | |
| 25 | - for app in proxied_apps.values(): | |
| 26 | - if not hasattr(app, 'menu'): | |
| 25 | + for app_name, app in proxied_apps.items(): | |
| 26 | + print app | |
| 27 | + if not app.get('menu'): | |
| 27 | 28 | continue |
| 28 | 29 | |
| 29 | - title = app.menu.get('title', app.label.title()) | |
| 30 | - links = app.menu.get('links', tuple()) | |
| 30 | + menu = app.get('menu') | |
| 31 | + title = menu.get('title', app_name) | |
| 32 | + links = menu.get('links', tuple()).items() | |
| 31 | 33 | if context['user'].is_active: |
| 32 | - links += app.menu.get('auth_links', tuple()) | |
| 34 | + links += menu.get('auth_links', tuple()).items() | |
| 33 | 35 | |
| 34 | 36 | if not links: |
| 35 | 37 | continue |
| ... | ... | @@ -38,8 +40,7 @@ def proxy_menu(context): |
| 38 | 40 | menu_links[title] = [] |
| 39 | 41 | |
| 40 | 42 | for text, link in links: |
| 41 | - url = reverse(app.label, args=(link,)) | |
| 42 | - menu_links[title].append((text, url)) | |
| 43 | + menu_links[title].append((text, link)) | |
| 43 | 44 | |
| 44 | 45 | menu = render_to_string('proxy/menu_template.html', |
| 45 | 46 | {'menu_links': menu_links}) | ... | ... |
colab/settings.py
| ... | ... | @@ -287,7 +287,6 @@ CONVERSEJS_BOSH_SERVICE_URL = SITE_URL + '/http-bind' |
| 287 | 287 | CONVERSEJS_ALLOW_CONTACT_REQUESTS = False |
| 288 | 288 | CONVERSEJS_SHOW_ONLY_ONLINE_USERS = True |
| 289 | 289 | |
| 290 | - | |
| 291 | 290 | # Tastypie settings |
| 292 | 291 | TASTYPIE_DEFAULT_FORMATS = ['json', ] |
| 293 | 292 | |
| ... | ... | @@ -317,8 +316,8 @@ for app_label in PROXIED_APPS.keys(): |
| 317 | 316 | |
| 318 | 317 | COLAB_APPS = locals().get('COLAB_APPS') or {} |
| 319 | 318 | |
| 320 | -for app in COLAB_APPS: | |
| 321 | - INSTALLED_APPS += (app,) | |
| 319 | +for app_name, app in COLAB_APPS.items(): | |
| 320 | + INSTALLED_APPS += (app_name,) | |
| 322 | 321 | |
| 323 | 322 | if not app or 'templates' not in app: |
| 324 | 323 | continue |
| ... | ... | @@ -326,6 +325,6 @@ for app in COLAB_APPS: |
| 326 | 325 | template = app.get('templates') |
| 327 | 326 | |
| 328 | 327 | if template.get('staticdir'): |
| 329 | - STATICFILES_DIRS += template.get('staticdir') | |
| 328 | + STATICFILES_DIRS += (template.get('staticdir'),) | |
| 330 | 329 | if template.get('templatesdir'): |
| 331 | - TEMPLATE_DIRS += template.get('templatesdir') | |
| 330 | + TEMPLATE_DIRS += (template.get('templatesdir'),) | ... | ... |