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,5 +17,5 @@ for app_name, app in settings.COLAB_APPS.items(): | ||
17 | raise ImproperlyConfigured(undef_url_include_msg) | 17 | raise ImproperlyConfigured(undef_url_include_msg) |
18 | urlpatterns += patterns('', | 18 | urlpatterns += patterns('', |
19 | url(urls.get('prefix', r''), include(urls['include'], | 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 | from django.apps import apps | 2 | from django.apps import apps |
3 | +from django.conf import settings | ||
3 | 4 | ||
4 | 5 | ||
5 | def proxied_apps(request): | 6 | def proxied_apps(request): |
6 | proxied_apps = {} | 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 | return {'proxy': proxied_apps} | 12 | return {'proxy': proxied_apps} |
colab/proxy/templatetags/proxy.py
@@ -22,14 +22,16 @@ def proxy_menu(context): | @@ -22,14 +22,16 @@ def proxy_menu(context): | ||
22 | menu_links = {} | 22 | menu_links = {} |
23 | proxied_apps = context.get('proxy', {}) | 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 | continue | 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 | if context['user'].is_active: | 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 | if not links: | 36 | if not links: |
35 | continue | 37 | continue |
@@ -38,8 +40,7 @@ def proxy_menu(context): | @@ -38,8 +40,7 @@ def proxy_menu(context): | ||
38 | menu_links[title] = [] | 40 | menu_links[title] = [] |
39 | 41 | ||
40 | for text, link in links: | 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 | menu = render_to_string('proxy/menu_template.html', | 45 | menu = render_to_string('proxy/menu_template.html', |
45 | {'menu_links': menu_links}) | 46 | {'menu_links': menu_links}) |
colab/settings.py
@@ -287,7 +287,6 @@ CONVERSEJS_BOSH_SERVICE_URL = SITE_URL + '/http-bind' | @@ -287,7 +287,6 @@ CONVERSEJS_BOSH_SERVICE_URL = SITE_URL + '/http-bind' | ||
287 | CONVERSEJS_ALLOW_CONTACT_REQUESTS = False | 287 | CONVERSEJS_ALLOW_CONTACT_REQUESTS = False |
288 | CONVERSEJS_SHOW_ONLY_ONLINE_USERS = True | 288 | CONVERSEJS_SHOW_ONLY_ONLINE_USERS = True |
289 | 289 | ||
290 | - | ||
291 | # Tastypie settings | 290 | # Tastypie settings |
292 | TASTYPIE_DEFAULT_FORMATS = ['json', ] | 291 | TASTYPIE_DEFAULT_FORMATS = ['json', ] |
293 | 292 | ||
@@ -317,8 +316,8 @@ for app_label in PROXIED_APPS.keys(): | @@ -317,8 +316,8 @@ for app_label in PROXIED_APPS.keys(): | ||
317 | 316 | ||
318 | COLAB_APPS = locals().get('COLAB_APPS') or {} | 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 | if not app or 'templates' not in app: | 322 | if not app or 'templates' not in app: |
324 | continue | 323 | continue |
@@ -326,6 +325,6 @@ for app in COLAB_APPS: | @@ -326,6 +325,6 @@ for app in COLAB_APPS: | ||
326 | template = app.get('templates') | 325 | template = app.get('templates') |
327 | 326 | ||
328 | if template.get('staticdir'): | 327 | if template.get('staticdir'): |
329 | - STATICFILES_DIRS += template.get('staticdir') | 328 | + STATICFILES_DIRS += (template.get('staticdir'),) |
330 | if template.get('templatesdir'): | 329 | if template.get('templatesdir'): |
331 | - TEMPLATE_DIRS += template.get('templatesdir') | 330 | + TEMPLATE_DIRS += (template.get('templatesdir'),) |