formdefs: allow usage of substitution variable in comments field (#5962)

This commit is contained in:
Frédéric Péters 2014-11-17 18:45:56 +01:00
parent ea589f1311
commit 2eebb7a997
2 changed files with 26 additions and 15 deletions

View File

@ -449,6 +449,9 @@ class CommentField(Field):
else:
label = self.label
from workflows import template_on_string
label = template_on_string(label)
if '<p' in label:
enclosing_tag = 'div'
else:

View File

@ -1310,24 +1310,32 @@ class SendmailWorkflowStatusItem(WorkflowStatusItem):
register_item_class(SendmailWorkflowStatusItem)
def template_on_formdata(formdata, template, process=None):
def template_on_string(template, process=None):
return template_on_formdata(None, template, process=process)
def template_on_formdata(formdata=None, template=None, process=None):
assert template is not None
if not '[' in template:
return template
dict = {}
dict.update(get_publisher().substitutions.get_context_variables())
dict['url'] = formdata.get_url()
dict['url_status'] = '%sstatus' % formdata.get_url()
dict['details'] = formdata.formdef.get_detailed_email_form(formdata, dict['url'])
dict['name'] = formdata.formdef.name
dict['number'] = formdata.id
if formdata.evolution and formdata.evolution[-1].comment:
dict['comment'] = formdata.evolution[-1].comment
else:
dict['comment'] = ''
dict.update(formdata.get_as_dict())
if formdata:
dict['url'] = formdata.get_url()
dict['url_status'] = '%sstatus' % formdata.get_url()
dict['details'] = formdata.formdef.get_detailed_email_form(formdata, dict['url'])
dict['name'] = formdata.formdef.name
dict['number'] = formdata.id
if formdata.evolution and formdata.evolution[-1].comment:
dict['comment'] = formdata.evolution[-1].comment
else:
dict['comment'] = ''
dict.update(formdata.get_as_dict())
# compatibility vars
dict['before'] = dict.get('form_previous_status')
dict['after'] = dict.get('form_status')
dict['evolution'] = dict.get('form_evolution')
# compatibility vars
dict['before'] = dict.get('form_previous_status')
dict['after'] = dict.get('form_status')
dict['evolution'] = dict.get('form_evolution')
if process:
for key in dict: