From: Kostas Papadimitriou Date: Mon, 3 Jun 2013 10:15:52 +0000 (+0300) Subject: Convert index view context to json X-Git-Tag: 0.14rc1~16 X-Git-Url: https://code.grnet.gr/git/pithos-web-client/commitdiff_plain/edb3e8efb0385367c788ae52033f953b2e17506e Convert index view context to json to safely append any type of values to otherProperties javascript object --- diff --git a/snf-pithos-webclient/pithos_webclient/templates/pithos_webclient/other_properties.html b/snf-pithos-webclient/pithos_webclient/templates/pithos_webclient/other_properties.html index dd70d47..acc5378 100644 --- a/snf-pithos-webclient/pithos_webclient/templates/pithos_webclient/other_properties.html +++ b/snf-pithos-webclient/pithos_webclient/templates/pithos_webclient/other_properties.html @@ -1,7 +1,7 @@ {% for key, value in branding_settings.items %} - otherProperties.{{ key }} = "{{ value }}"; + otherProperties.{{ key }} = {{ value|safe }}; {% endfor %} {% for key, value in urls_config.items %} - otherProperties.{{ key }} = "{{ value }}"; + otherProperties.{{ key }} = "{{ value|safe }}"; {% endfor %} diff --git a/snf-pithos-webclient/pithos_webclient/views.py b/snf-pithos-webclient/pithos_webclient/views.py index 5fcf306..6ecb3dd 100644 --- a/snf-pithos-webclient/pithos_webclient/views.py +++ b/snf-pithos-webclient/pithos_webclient/views.py @@ -31,17 +31,20 @@ # interpreted as representing official policies, either expressed # or implied, of GRNET S.A. +import json +import copy + from django.views.generic.simple import direct_to_template +from django.conf import settings as django_settings from pithos_webclient import settings -from pithos_webclient.version import __version__ - -from django.conf import settings as django_settings +from pithos_webclient.version import __version__ from synnefo_branding.utils import get_branding_dict -MEDIA_URL = getattr(settings, "PITHOS_WEB_CLIENT_MEDIA_URL", \ - getattr(django_settings, "MEDIA_URL", "/static/")) + +MEDIA_URL = getattr(settings, "PITHOS_WEB_CLIENT_MEDIA_URL", + getattr(django_settings, "MEDIA_URL", "/static/")) URLS_CONFIG = { 'STORAGE_API_URL': settings.PITHOS_URL.rstrip('/') + '/', @@ -53,6 +56,14 @@ URLS_CONFIG = { def index(request): branding_settings = get_branding_dict("") + urls_config = copy.deepcopy(URLS_CONFIG) + + for key, value in urls_config.iteritems(): + urls_config[key] = json.dumps(value) + + for key, value in branding_settings.iteritems(): + branding_settings[key] = json.dumps(value) + return direct_to_template(request, 'pithos_webclient/index.html', { 'settings': settings, 'MEDIA_URL': MEDIA_URL,