3236 |
3236 |
}
|
3237 |
3237 |
|
3238 |
3238 |
|
|
3239 |
def test_backoffice_workflow_form_with_other_buttons(pub):
|
|
3240 |
user = create_user(pub)
|
|
3241 |
create_environment(pub)
|
|
3242 |
|
|
3243 |
wf = Workflow.get_default_workflow()
|
|
3244 |
wf.id = '2'
|
|
3245 |
wf.store()
|
|
3246 |
wf = Workflow.get(wf.id)
|
|
3247 |
status = wf.get_status('new')
|
|
3248 |
status.items = []
|
|
3249 |
display_form = status.add_action('form', id='_display_form')
|
|
3250 |
display_form.by = [user.roles[0]]
|
|
3251 |
display_form.varname = 'blah'
|
|
3252 |
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
|
3253 |
display_form.formdef.fields.append(
|
|
3254 |
fields.StringField(id='1', label='Test', varname='str', type='string', required=True)
|
|
3255 |
)
|
|
3256 |
choice_ok = status.add_action('choice', id='_ok')
|
|
3257 |
choice_ok.label = 'OK'
|
|
3258 |
choice_ok.status = 'accepted'
|
|
3259 |
choice_ok.by = [user.roles[0]]
|
|
3260 |
|
|
3261 |
choice_ko = status.add_action('choice', id='_ko')
|
|
3262 |
choice_ko.label = 'KO'
|
|
3263 |
choice_ko.status = 'accepted'
|
|
3264 |
choice_ko.ignore_form_errors = True
|
|
3265 |
choice_ko.by = [user.roles[0]]
|
|
3266 |
|
|
3267 |
jump = status.add_action('jumponsubmit', id='_jump')
|
|
3268 |
jump.status = 'accepted'
|
|
3269 |
|
|
3270 |
wf.store()
|
|
3271 |
formdef = FormDef.get_by_urlname('form-title')
|
|
3272 |
formdef.workflow_id = wf.id
|
|
3273 |
formdef.store()
|
|
3274 |
|
|
3275 |
for button_name in ('submit', 'button_ok', 'button_ko'):
|
|
3276 |
formdata = formdef.data_class()()
|
|
3277 |
formdata.data = {}
|
|
3278 |
formdata.just_created()
|
|
3279 |
formdata.jump_status('new')
|
|
3280 |
formdata.store()
|
|
3281 |
|
|
3282 |
app = login(get_app(pub))
|
|
3283 |
resp = app.get(formdata.get_url(backoffice=True))
|
|
3284 |
resp.form['fblah_1'] = 'blah'
|
|
3285 |
resp = resp.form.submit(button_name)
|
|
3286 |
|
|
3287 |
formdata.refresh_from_storage()
|
|
3288 |
pub.substitutions.reset()
|
|
3289 |
pub.substitutions.feed(formdata)
|
|
3290 |
context = pub.substitutions.get_context_variables(mode='lazy')
|
|
3291 |
assert formdata.status == 'wf-accepted'
|
|
3292 |
if button_name == 'button_ko':
|
|
3293 |
assert context['form_workflow_data_blah_var_str'] == 'blah' # leak
|
|
3294 |
with pytest.raises(KeyError):
|
|
3295 |
assert context['form_workflow_form_blah_var_str'] == 'blah'
|
|
3296 |
else:
|
|
3297 |
assert context['form_workflow_form_blah_var_str'] == 'blah'
|
|
3298 |
assert context['form_workflow_data_blah_var_str'] == 'blah'
|
|
3299 |
|
|
3300 |
|
3239 |
3301 |
def test_backoffice_criticality_formdata_view(pub):
|
3240 |
3302 |
create_user(pub)
|
3241 |
3303 |
create_environment(pub)
|