From 7c97a6c4cdc9d7557f20f91630bbaa7b49218dd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 5 May 2015 11:23:27 +0200 Subject: [PATCH] backoffice: export list of menu items as json (#7146) --- wcs/backoffice/root.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/wcs/backoffice/root.py b/wcs/backoffice/root.py index f11e529..81b032d 100644 --- a/wcs/backoffice/root.py +++ b/wcs/backoffice/root.py @@ -453,7 +453,7 @@ class ManagementDirectory(Directory): class RootDirectory(BackofficeRootDirectory): - _q_exports = ['', 'pending', 'statistics'] + _q_exports = ['', 'pending', 'statistics', ('menu.json', 'menu_json')] bounces = wcs.admin.bounces.BouncesDirectory() categories = wcs.admin.categories.CategoriesDirectory() @@ -581,6 +581,17 @@ class RootDirectory(BackofficeRootDirectory): return r.getvalue() + def menu_json(self): + get_response().set_content_type('application/json') + if get_request().get_environ('HTTP_ORIGIN'): + get_response().set_header('Access-Control-Allow-Origin', + get_request().get_environ('HTTP_ORIGIN')) + get_response().set_header('Access-Control-Allow-Credentials', 'true') + get_response().set_header('Access-Control-Allow-Headers', 'x-requested-with') + menu_items = [] + backoffice_url = get_publisher().get_backoffice_url() + return json.dumps(self.get_menu_items()) + def pending(self): # kept as a redirection for compatibility with possible bookmarks return redirect('.') -- 2.1.4