Files
mayan-edms/mayan/apps/templating/forms.py
Roberto Rosario 913e57a010 Show the available variable in the help text
Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
2019-12-10 22:31:08 -04:00

27 lines
990 B
Python

from __future__ import absolute_import, unicode_literals
from django import forms
from django.utils.translation import ugettext_lazy as _
from .fields import TemplateField
class DocumentTemplateSandboxForm(forms.Form):
result = forms.CharField(
help_text=_('Resulting text from the evaluated template.'),
label=_('Result'), required=False, widget=forms.widgets.Textarea(
attrs={'readonly': 'readonly', 'rows': 5}
)
)
def __init__(self, *args, **kwargs):
self.model = kwargs.pop('model')
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
)
self.order_fields(field_order=('template', 'result'))