backoffice: export list of menu items as json (#7146)
This commit is contained in:
parent
31db8c2613
commit
1be0db51de
|
@ -43,7 +43,7 @@ from . import management
|
||||||
|
|
||||||
|
|
||||||
class RootDirectory(BackofficeRootDirectory):
|
class RootDirectory(BackofficeRootDirectory):
|
||||||
_q_exports = ['', 'pending', 'statistics']
|
_q_exports = ['', 'pending', 'statistics', ('menu.json', 'menu_json')]
|
||||||
|
|
||||||
bounces = wcs.admin.bounces.BouncesDirectory()
|
bounces = wcs.admin.bounces.BouncesDirectory()
|
||||||
categories = wcs.admin.categories.CategoriesDirectory()
|
categories = wcs.admin.categories.CategoriesDirectory()
|
||||||
|
@ -199,6 +199,17 @@ class RootDirectory(BackofficeRootDirectory):
|
||||||
|
|
||||||
return r.getvalue()
|
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):
|
def pending(self):
|
||||||
# kept as a redirection for compatibility with possible bookmarks
|
# kept as a redirection for compatibility with possible bookmarks
|
||||||
return redirect('.')
|
return redirect('.')
|
||||||
|
|
Loading…
Reference in New Issue