backoffice: export list of menu items as json (#7146)

This commit is contained in:
Frédéric Péters 2015-05-05 11:23:27 +02:00
parent 31db8c2613
commit 1be0db51de
1 changed files with 12 additions and 1 deletions

View File

@ -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('.')