misc: set qommon/l10n as builtin templatetags in settings (#37275)

This commit is contained in:
Frédéric Péters 2020-02-17 19:58:56 +01:00
parent 1940f8dc7a
commit 09081c7f1f
8 changed files with 7 additions and 14 deletions

View File

@ -70,8 +70,7 @@ class Condition(object):
return eval(self.value, global_variables, local_variables)
def evaluate_django(self, local_variables):
template = Template('{%% load %s %%}{%% if %s %%}OK{%% endif %%}' % (
get_publisher().get_default_templatetags_libraries(), self.value))
template = Template('{%% if %s %%}OK{%% endif %%}' % self.value)
context = Context(local_variables)
return template.render(context) == 'OK'
@ -92,7 +91,6 @@ class Condition(object):
def validate_django(self):
try:
Template('{%% load %s %%}{%% if %s %%}OK{%% endif %%}' % (
get_publisher().get_default_templatetags_libraries(), self.value))
Template('{%% if %s %%}OK{%% endif %%}' % self.value)
except TemplateSyntaxError as e:
raise ValidationError(_('syntax error: %s') % force_str(force_text(e)))

View File

@ -843,10 +843,6 @@ class QommonPublisher(Publisher, object):
default_position = '50.84;4.36'
return default_position
def get_default_templatetags_libraries(self):
libraries = self.get_site_option('default_templatetags_libraries') or ''
return 'qommon l10n %s' % libraries
def get_map_attributes(self):
attrs = {}
attrs['data-def-lat'], attrs['data-def-lng'] = self.get_default_position().split(';')

View File

@ -471,8 +471,6 @@ class Template(object):
self.render = self.django_render
if autoescape is False:
value = '{%% autoescape off %%}%s{%% endautoescape %%}' % value
value = '{%% load %s %%}%s' % (
get_publisher().get_default_templatetags_libraries(), value)
try:
self.template = engines['django'].from_string(value)
except DjangoTemplateSyntaxError as e:

View File

@ -1,4 +1,3 @@
{% load qommon %}
<div class="widget {{widget.class_name}} {{widget.extra_css_class}}
{% if widget.readonly %}widget-readonly{% endif %}
{% if widget.get_error %}widget-with-error{% endif %}

View File

@ -104,6 +104,10 @@ TEMPLATES = [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
],
'builtins': [
'wcs.qommon.templatetags.qommon',
'django.templatetags.l10n',
],
},
},
]

View File

@ -1,5 +1,4 @@
{% extends "gadjo/base.html" %}
{% load qommon %}
{% block page-title %}{{ page_title }}{% endblock %}
{% block site-title %}{{ site_name }}{% endblock %}

View File

@ -1,5 +1,5 @@
{% extends template_base %}
{% load i18n qommon %}
{% load i18n %}
{% block body %}

View File

@ -1,5 +1,4 @@
{% extends template_base %}
{% load qommon %}
{% block body %}
<div class="form-validation">