misc: add user and session in multi action context (#49036)
This commit is contained in:
parent
7138d09c3b
commit
4dc514c98c
|
@ -1609,6 +1609,43 @@ def test_backoffice_multi_actions_oldest_form(pub):
|
|||
'<p>Original form: %s.</p>' % oldest_formdata.get_display_id())
|
||||
|
||||
|
||||
def test_backoffice_multi_actions_using_session_user(pub):
|
||||
create_superuser(pub)
|
||||
create_environment(pub)
|
||||
formdef = FormDef.get_by_urlname('form-title')
|
||||
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/management/form-title/')
|
||||
assert 'id="multi-actions"' in resp.text # always there
|
||||
|
||||
workflow = Workflow.get_default_workflow()
|
||||
workflow.id = '2'
|
||||
action = workflow.add_global_action('Show user')
|
||||
register_comment = action.append_item('register-comment')
|
||||
register_comment.comment = 'session_user={{session_user}}'
|
||||
trigger = action.triggers[0]
|
||||
trigger.roles = [x.id for x in Role.select() if x.name == 'foobar']
|
||||
|
||||
workflow.store()
|
||||
formdef.workflow_id = workflow.id
|
||||
formdef.store()
|
||||
|
||||
resp = app.get('/backoffice/management/form-title/')
|
||||
assert 'id="multi-actions"' in resp.text
|
||||
ids = []
|
||||
for checkbox in resp.forms[0].fields['select[]'][1:6]:
|
||||
ids.append(checkbox._value)
|
||||
checkbox.checked = True
|
||||
resp = resp.forms[0].submit('button-action-1')
|
||||
assert '?job=' in resp.location
|
||||
resp = resp.follow()
|
||||
assert 'Executing task "Show user" on forms' in resp.text
|
||||
assert '>completed<' in resp.text
|
||||
for i, id in enumerate(sorted(ids, key=lambda x: int(x))):
|
||||
content = formdef.data_class().get(id).evolution[-1].parts[0].content
|
||||
assert 'session_user=admin' in content
|
||||
|
||||
|
||||
def test_backoffice_statistics_with_no_formdefs(pub):
|
||||
create_user(pub)
|
||||
create_environment(pub)
|
||||
|
|
|
@ -1968,6 +1968,7 @@ class FormPage(Directory):
|
|||
for i, formdata in enumerate(formdatas):
|
||||
publisher.substitutions.reset()
|
||||
publisher.substitutions.feed(publisher)
|
||||
publisher.substitutions.feed(self.user)
|
||||
publisher.substitutions.feed(self.formdef)
|
||||
publisher.substitutions.feed(formdata)
|
||||
publisher.substitutions.feed({
|
||||
|
|
Loading…
Reference in New Issue