From 526a5478f7c690a90c7e45bc9a04c0d0882e7eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Thu, 1 Dec 2016 15:21:11 +0100 Subject: [PATCH] Added settings for client to basic JavaScript code on client startup. Closed #2697. --- openslides/core/views.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/openslides/core/views.py b/openslides/core/views.py index 0e087d30f..5e187e6e8 100644 --- a/openslides/core/views.py +++ b/openslides/core/views.py @@ -141,6 +141,18 @@ class WebclientJavaScriptView(utils_views.View): else: js_files.extend(app_js_files) + client_settings_keys = [ + # Add new settings to personal settings.py, utils/settings.py.tpl and to this list. Remove this comment later. + ] + client_settings = {} + for key in client_settings_keys: + try: + client_settings[key] = getattr(settings, key) + except AttributeError: + # Settings key does not exist. Do nothing. The client will + # treat this as undefined. + pass + # Use JavaScript loadScript function from # http://balpha.de/2011/10/jquery-script-insertion-and-its-consequences-for-debugging/ # jQuery is required. @@ -167,13 +179,14 @@ class WebclientJavaScriptView(utils_views.View): }; """ + """ - angular.module('OpenSlidesApp.{realm}', {angular_modules}); + angular.module('OpenSlidesApp.{realm}', {angular_modules}) + .constant('OpenSlidesSettings', {settings}); var deferres = []; {js_files}.forEach( function(js_file) {{ deferres.push(loadScript(js_file)); }} ); $.when.apply(this,deferres).done( function() {{ angular.bootstrap(document,['OpenSlidesApp.{realm}']); }} ); - """.format(realm=realm, angular_modules=angular_modules, js_files=js_files) + + """.format(realm=realm, angular_modules=angular_modules, settings=client_settings, js_files=js_files) + """ }()); """)