misc: add session user info to global interactive action execution (#77781) #330
|
@ -23,6 +23,7 @@ from wcs.qommon.upload_storage import PicklableUpload
|
|||
from wcs.roles import logged_users_role
|
||||
from wcs.wf.create_formdata import Mapping
|
||||
from wcs.wf.form import WorkflowFormFieldsFormDef
|
||||
from wcs.wf.register_comment import JournalEvolutionPart
|
||||
from wcs.workflows import Workflow, WorkflowBackofficeFieldsFormDef, WorkflowCriticalityLevel
|
||||
from wcs.wscalls import NamedWsCall
|
||||
|
||||
|
@ -1092,7 +1093,7 @@ def test_backoffice_multi_actions_interactive(pub):
|
|||
)
|
||||
form_action.hide_submit_button = False
|
||||
register_comment = action.add_action('register-comment')
|
||||
register_comment.comment = 'HELLO {{ form_workflow_form_blah_var_test }}'
|
||||
register_comment.comment = 'HELLO {{ session_user }}'
|
||||
|
||||
trigger = action.triggers[0]
|
||||
trigger.roles = [x.id for x in pub.role_class.select() if x.name == 'foobar']
|
||||
|
@ -1143,6 +1144,10 @@ def test_backoffice_multi_actions_interactive(pub):
|
|||
context = pub.substitutions.get_context_variables(mode='lazy')
|
||||
if str(formdata.id) in ids:
|
||||
assert context['form_workflow_form_blah_var_test'].get_value() == 'GLOBAL INTERACTIVE ACTION'
|
||||
history_message = [
|
||||
x for x in formdata.iter_evolution_parts() if isinstance(x, JournalEvolutionPart)
|
||||
][-1]
|
||||
assert 'HELLO admin' in history_message.content
|
||||
else:
|
||||
with pytest.raises(KeyError):
|
||||
assert context['form_workflow_form_blah_var_test']
|
||||
|
|
|
@ -228,6 +228,8 @@ class GlobalInteractiveMassActionAfterJob(AfterJob):
|
|||
@classmethod
|
||||
def execute_one(cls, publisher, formdata, action, user, afterjob=True):
|
||||
publisher.reset_formdata_state()
|
||||
publisher.substitutions.feed(user)
|
||||
publisher.substitutions.feed(formdata.formdef)
|
||||
publisher.substitutions.feed(formdata)
|
||||
|
||||
status = formdata.status
|
||||
|
|
Loading…
Reference in New Issue