simple uds tags fixes

This commit is contained in:
Adolfo Gómez García 2018-05-11 12:06:00 +02:00
parent 15e4c949d3
commit af53a574f5
2 changed files with 13 additions and 5 deletions

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012 Virtual Cable S.L.
# Copyright (c) 2012-2018 Virtual Cable S.L.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
@ -46,8 +46,6 @@ import logging
logger = logging.getLogger(__name__)
__updated__ = '2017-04-17'
# Default ssl context is unverified, as MOST servers that we will connect will be with self signed certificates...
try:

View File

@ -32,8 +32,8 @@
"""
from django import template
from django.utils.translation import ugettext as _
from django.templatetags.static import static
from django.utils.translation import gettext, get_language
from django.conf import settings
from django.utils.html import mark_safe
import json
@ -59,3 +59,13 @@ def javascript_auths(authenticators):
'isCustom': theType.isCustom()
})
return mark_safe('<script type="text/javascript">\nvar authenticators = ' + json.dumps(res, indent=4) + ';\n</script>')
@register.simple_tag
def jsdata():
udsConfig = {
'language': get_language(),
'available_languages': [(k, gettext(v)) for k, v in settings.LANGUAGES]
}
javascript = 'var udsConfig = ' + json.dumps(udsConfig) + ';';
return mark_safe('<script type="text/javascript">{}\n</script>'.format(javascript))