Show the available variable in the help text

Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-12-10 22:31:08 -04:00
parent 1ee449d894
commit 913e57a010
3 changed files with 9 additions and 3 deletions

View File

@@ -13,6 +13,8 @@
- Don't show the edit and delete links for resolved web links.
- Exclude Smart link setup columns and links from the resolved
smart link views.
- TemplateField shows the available variable in the help text
automatically.
3.3.4 (2019-12-09)
==================

View File

@@ -19,10 +19,13 @@ class TemplateField(forms.CharField):
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__}
'(https://docs.djangoproject.com/en/%(django_version)s/ref/templates/builtins/). '
'The {{ %(variable)s }} variable is available to the template.'
) % {
'django_version': mayan.__django_version__,
'variable': self.model_variable
}
)
self.widget.attrs['model'] = self.model
self.widget.attrs['data-model-variable'] = self.model_variable

View File

@@ -19,6 +19,7 @@ class DocumentTemplateSandboxForm(forms.Form):
self.model_variable = kwargs.pop('model_variable')
super(DocumentTemplateSandboxForm, self).__init__(*args, **kwargs)
self.fields['template'] = TemplateField(
initial_help_text=_('The template string to be evaluated.'),
label=_('Template'), model=self.model,
model_variable=self.model_variable, required=False
)