diff --git a/wcs/backoffice/root.py b/wcs/backoffice/root.py index ec329061b..d9095a5b1 100644 --- a/wcs/backoffice/root.py +++ b/wcs/backoffice/root.py @@ -43,7 +43,7 @@ from . import management 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() @@ -199,6 +199,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('.')