Update TemplateField to concatenate help texts

Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-12-10 20:47:59 -04:00
parent a7cf6b5664
commit 88d29ecfc0
2 changed files with 11 additions and 6 deletions

View File

@@ -9,6 +9,7 @@
- Unify the creation of the temporary config file used in tests.
- Update all 0001 setting migrations to not accept manually migrated
settings.
- Update TemplateField to concatenate existing help texts.
3.3.4 (2019-12-09)
==================

View File

@@ -1,7 +1,7 @@
from __future__ import absolute_import, unicode_literals
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import string_concat, ugettext_lazy as _
import mayan
@@ -14,11 +14,15 @@ class TemplateField(forms.CharField):
def __init__(self, *args, **kwargs):
self.model = kwargs.pop('model')
self.model_variable = kwargs.pop('model_variable')
self.initial_help_text = kwargs.pop('initial_help_text', '')
super(TemplateField, self).__init__(*args, **kwargs)
self.help_text = _(
'The template string to be evaluated. '
'Use Django\'s default templating language '
'(https://docs.djangoproject.com/en/%(django_version)s/ref/templates/builtins/)'
) % {'django_version': mayan.__django_version__}
self.help_text = string_concat(
self.initial_help_text, ' ',
_(
'The template string to be evaluated. '
'Use Django\'s default templating language '
'(https://docs.djangoproject.com/en/%(django_version)s/ref/templates/builtins/)'
) % {'django_version': mayan.__django_version__}
)
self.widget.attrs['model'] = self.model
self.widget.attrs['data-model-variable'] = self.model_variable