Move list of additional variable near template_on_formdata where they are defined in workflows.py
This commit is contained in:
parent
baf48ee3bd
commit
aee0f8e5fe
|
@ -29,13 +29,18 @@ from anonylink import AnonymityLink
|
|||
def get_dict_with_varnames(fields, data):
|
||||
new_data = {}
|
||||
for field in fields:
|
||||
value = data.get(field.id)
|
||||
if data is not None:
|
||||
value = data.get(field.id)
|
||||
else:
|
||||
value = field.label
|
||||
# add it as f$n$
|
||||
new_data['f%s' % field.id] = value
|
||||
if data is not None or not field.variable:
|
||||
new_data['f%s' % field.id] = value
|
||||
|
||||
# also add it as 'field_' + normalized(field label)
|
||||
identifier_name = qommon.misc.simplify(field.label, space = '_')
|
||||
new_data['field_' + identifier_name] = value
|
||||
if data is not None:
|
||||
new_data['field_' + identifier_name] = value
|
||||
|
||||
# and finally add it as its manually defined variable name
|
||||
if field.varname:
|
||||
|
|
|
@ -48,13 +48,6 @@ class TemplatingError(qommon.errors.PublishError):
|
|||
self.title = _('Templating Error')
|
||||
self.description = description
|
||||
|
||||
ADDITIONAL_VARIABLES = (
|
||||
('url', _('URL of the form')),
|
||||
('url_status', _('URL of the form status')),
|
||||
('details', _('Full details of the form')),
|
||||
('name', _('Form type')),
|
||||
('number', _('Form number')))
|
||||
|
||||
def get_varnames(fields):
|
||||
'''Extract variable names for helping people fill their templates.
|
||||
|
||||
|
@ -582,6 +575,16 @@ class SendmailWorkflowStatusItem(WorkflowStatusItem):
|
|||
fire_and_forget=True)
|
||||
register_item_class(SendmailWorkflowStatusItem)
|
||||
|
||||
|
||||
ADDITIONAL_VARIABLES = (
|
||||
('url', _('URL of the form')),
|
||||
('url_status', _('URL of the form status')),
|
||||
('details', _('Full details of the form')),
|
||||
('name', _('Form type')),
|
||||
('number', _('Form number')),
|
||||
('comment', _('Last comment')),)
|
||||
|
||||
|
||||
def template_on_formdata(formdata, template, process=None):
|
||||
dict = {}
|
||||
dict['url'] = formdata.get_url()
|
||||
|
|
Loading…
Reference in New Issue