summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2015-05-06 08:31:07 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2015-05-20 09:15:17 (GMT)
commitc667a9018af112b3857b834b94bd8a80a6b815d3 (patch)
treef33ac756dc79e20a2fd752526db57b3d8441c983
parentb8042003581f80eabd34657c585c437532b8e5ce (diff)
downloadcombo-c667a9018af112b3857b834b94bd8a80a6b815d3.zip
combo-c667a9018af112b3857b834b94bd8a80a6b815d3.tar.gz
combo-c667a9018af112b3857b834b94bd8a80a6b815d3.tar.bz2
manager: export management access entry point as json (#7155)
-rw-r--r--combo/manager/urls.py1
-rw-r--r--combo/manager/views.py19
2 files changed, 20 insertions, 0 deletions
diff --git a/combo/manager/urls.py b/combo/manager/urls.py
index 26ee722..803e5bb 100644
--- a/combo/manager/urls.py
+++ b/combo/manager/urls.py
@@ -21,6 +21,7 @@ from . import views
urlpatterns = patterns('combo.views',
url(r'^$', views.homepage, name='combo-manager-homepage'),
+ url(r'^menu.json$', views.menu_json),
url(r'^site-export$', views.site_export, name='combo-manager-site-export'),
url(r'^site-import$', views.site_import, name='combo-manager-site-import'),
url(r'^pages/add/$', views.page_add, name='combo-manager-page-add'),
diff --git a/combo/manager/views.py b/combo/manager/views.py
index abc99a7..b907130 100644
--- a/combo/manager/views.py
+++ b/combo/manager/views.py
@@ -26,6 +26,7 @@ from django.core.urlresolvers import reverse, reverse_lazy
from django.http import HttpResponse, Http404
from django.shortcuts import redirect
from django.utils.translation import ugettext_lazy as _
+from django.utils.encoding import force_text
from django.views.decorators.csrf import requires_csrf_token
from django.views.generic import (TemplateView, RedirectView, DetailView,
CreateView, UpdateView, ListView, DeleteView, FormView)
@@ -307,3 +308,21 @@ def asset_delete(request):
raise PermissionDenied()
default_storage.delete(img_orig);
return HttpResponse(status=204)
+
+
+def menu_json(request):
+ response = HttpResponse(content_type='application/json')
+ if getattr(settings, 'TEMPLATE_VARS', {}).get('site_title'):
+ label = _('Editing %(site_title)s') % getattr(settings, 'TEMPLATE_VARS')
+ else:
+ label = _('Content Management')
+ json_str = json.dumps([{'label': force_text(label),
+ 'slug': 'portal',
+ 'url': request.build_absolute_uri(reverse('combo-manager-homepage'))
+ }])
+ for variable in ('jsonpCallback', 'callback'):
+ if variable in request.GET:
+ json_str = '%s(%s);' % (request.GET[variable], json_str)
+ break
+ response.write(json_str)
+ return response