78 |
78 |
return user1
|
79 |
79 |
|
80 |
80 |
def create_superuser(pub):
|
81 |
|
create_user(pub, is_admin=True)
|
|
81 |
return create_user(pub, is_admin=True)
|
82 |
82 |
|
83 |
83 |
def create_environment(pub, set_receiver=True):
|
84 |
84 |
Workflow.wipe()
|
... | ... | |
958 |
958 |
account.store()
|
959 |
959 |
app2 = login(get_app(pub), username='foobar', password='foobar')
|
960 |
960 |
resp = app2.get('/backoffice/management/form-title/%s/' % number31.id)
|
961 |
|
assert 'Be warned this form is also being' in resp.body
|
|
961 |
assert 'Be warned forms of this user are also being looked' in resp.body
|
962 |
962 |
assert not 'backoffice-description' in resp.body
|
963 |
963 |
assert not 'CLICK ME!' in resp.body
|
964 |
964 |
assert not 'CLICK ME2!' in resp.body
|
... | ... | |
2514 |
2514 |
assert not 'advisory-lock' in resp.body
|
2515 |
2515 |
|
2516 |
2516 |
resp = app.get('/backoffice/management/form-title/' + first_link)
|
2517 |
|
assert not 'Be warned this form is also being' in resp.body
|
|
2517 |
assert not 'Be warned forms of this user are also being looked' in resp.body
|
2518 |
2518 |
assert 'button_commentable' in resp.body
|
2519 |
2519 |
assert len(resp.forms) == 1
|
2520 |
2520 |
resp = app2.get('/backoffice/management/form-title/' + first_link)
|
2521 |
|
assert 'Be warned this form is also being' in resp.body
|
|
2521 |
assert 'Be warned forms of this user are also being looked' in resp.body
|
2522 |
2522 |
assert not 'button_commentable' in resp.body
|
2523 |
2523 |
assert len(resp.forms) == 0
|
2524 |
2524 |
# revisit with first user, no change
|
2525 |
2525 |
resp = app.get('/backoffice/management/form-title/' + first_link)
|
2526 |
|
assert not 'Be warned this form is also being' in resp.body
|
|
2526 |
assert not 'Be warned forms of this user are also being looked' in resp.body
|
2527 |
2527 |
assert 'button_commentable' in resp.body
|
2528 |
2528 |
# back to second
|
2529 |
2529 |
resp = app2.get('/backoffice/management/form-title/' + first_link)
|
2530 |
|
assert 'Be warned this form is also being' in resp.body
|
|
2530 |
assert 'Be warned forms of this user are also being looked' in resp.body
|
2531 |
2531 |
assert not 'button_commentable' in resp.body
|
2532 |
2532 |
resp = resp.click('(unlock actions)')
|
2533 |
2533 |
resp = resp.follow()
|
2534 |
|
assert 'Be warned this form is also being' in resp.body
|
|
2534 |
assert 'Be warned forms of this user are also being looked' in resp.body
|
2535 |
2535 |
assert 'button_commentable' in resp.body
|
2536 |
2536 |
assert not '(unlock actions)' in resp.body
|
2537 |
2537 |
assert len(resp.forms) == 1
|
... | ... | |
2549 |
2549 |
assert not 'advisory-lock' in app2.get('/backoffice/management/form-title/')
|
2550 |
2550 |
assert 'advisory-lock' in app.get('/backoffice/management/form-title/')
|
2551 |
2551 |
|
|
2552 |
def test_backoffice_advisory_lock_related_formdatas(pub):
|
|
2553 |
if not pub.is_using_postgresql():
|
|
2554 |
pytest.skip('this requires SQL')
|
|
2555 |
return
|
|
2556 |
pub.session_manager.session_class.wipe()
|
|
2557 |
user = create_superuser(pub)
|
|
2558 |
create_environment(pub)
|
|
2559 |
|
|
2560 |
formdef = FormDef.get_by_urlname('form-title')
|
|
2561 |
formdatas = formdef.data_class().select(lambda x: x.status == 'wf-new')
|
|
2562 |
|
|
2563 |
second_user = pub.user_class(name='foobar')
|
|
2564 |
second_user.roles = Role.keys()
|
|
2565 |
second_user.store()
|
|
2566 |
account = PasswordAccount(id='foobar')
|
|
2567 |
account.set_password('foobar')
|
|
2568 |
account.user_id = second_user.id
|
|
2569 |
account.store()
|
|
2570 |
|
|
2571 |
third_user = pub.user_class(name='user')
|
|
2572 |
third_user.store()
|
|
2573 |
|
|
2574 |
for formdata in formdatas[:2]:
|
|
2575 |
formdata.user_id = third_user.id
|
|
2576 |
formdata.store()
|
|
2577 |
|
|
2578 |
second_formdef = FormDef.get_by_urlname('other-form')
|
|
2579 |
second_formdef.workflow_roles = {}
|
|
2580 |
second_formdef.store()
|
|
2581 |
other_formdatas = second_formdef.data_class().select(lambda x: x.status == 'wf-new')
|
|
2582 |
other_formdatas[0].user_id = third_user.id
|
|
2583 |
other_formdatas[0].store()
|
|
2584 |
|
|
2585 |
app = login(get_app(pub))
|
|
2586 |
resp = app.get('/backoffice/management/form-title/%s/' % formdatas[0].id)
|
|
2587 |
assert not 'Be warned forms of this user are also being looked' in resp.body
|
|
2588 |
|
|
2589 |
app2 = login(get_app(pub), username='foobar', password='foobar')
|
|
2590 |
resp2 = app2.get('/backoffice/management/form-title/%s/' % formdatas[0].id)
|
|
2591 |
assert 'Be warned forms of this user are also being looked' in resp2.body
|
|
2592 |
|
|
2593 |
# another by the same user
|
|
2594 |
resp2 = app2.get('/backoffice/management/form-title/%s/' % formdatas[1].id)
|
|
2595 |
assert 'Be warned forms of this user are also being looked' in resp2.body
|
|
2596 |
|
|
2597 |
# another by another user
|
|
2598 |
resp2 = app2.get('/backoffice/management/form-title/%s/' % formdatas[3].id)
|
|
2599 |
assert not 'Be warned forms of this user are also being looked' in resp2.body
|
|
2600 |
|
|
2601 |
# check another formdef is only marked as visited if the user has potential
|
|
2602 |
# actions on it.
|
|
2603 |
session = pub.session_manager.session_class.select(lambda x: x.user == user.id)[0]
|
|
2604 |
second_formdef.workflow_roles = {'_receiver': 1}
|
|
2605 |
second_formdef.store()
|
|
2606 |
other_formdata = second_formdef.data_class().get(other_formdatas[0].id)
|
|
2607 |
other_formdata.store() # update concerned_roles
|
|
2608 |
|
|
2609 |
assert not 'formdata-other-form-%d' % other_formdata.id in session.visiting_objects.keys()
|
|
2610 |
session.visiting_objects = {}
|
|
2611 |
session.store()
|
|
2612 |
|
|
2613 |
resp = app.get('/backoffice/management/form-title/%s/' % formdatas[0].id)
|
|
2614 |
session = pub.session_manager.session_class.select(lambda x: x.user == user.id)[0]
|
|
2615 |
assert 'formdata-other-form-%d' % other_formdata.id in session.visiting_objects.keys()
|
|
2616 |
|
2552 |
2617 |
def test_backoffice_resubmit(pub):
|
2553 |
2618 |
user = create_user(pub)
|
2554 |
2619 |
create_environment(pub)
|