diff --git a/HISTORY.rst b/HISTORY.rst index 9ecf64d934..d4a5198572 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -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) ================== diff --git a/mayan/apps/templating/fields.py b/mayan/apps/templating/fields.py index 44f916401e..280cd8f33e 100644 --- a/mayan/apps/templating/fields.py +++ b/mayan/apps/templating/fields.py @@ -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 diff --git a/mayan/apps/templating/forms.py b/mayan/apps/templating/forms.py index 05c1abff59..1318c499b5 100644 --- a/mayan/apps/templating/forms.py +++ b/mayan/apps/templating/forms.py @@ -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 )