798 |
798 |
role = pub.role_class(name='test')
|
799 |
799 |
role.store()
|
800 |
800 |
|
|
801 |
local_user.roles = [role.id]
|
|
802 |
local_user.store()
|
|
803 |
|
|
804 |
Workflow.wipe()
|
|
805 |
workflow = Workflow()
|
|
806 |
workflow.add_status('Status1', 'st1')
|
|
807 |
workflow.add_status('Status2', 'st2')
|
|
808 |
workflow.possible_status[-1].visibility = [role.id]
|
|
809 |
workflow.store()
|
|
810 |
|
801 |
811 |
FormDef.wipe()
|
802 |
812 |
formdef = FormDef()
|
803 |
813 |
formdef.name = 'test'
|
... | ... | |
809 |
819 |
),
|
810 |
820 |
fields.FileField(id='2', label='foobar4', varname='file'),
|
811 |
821 |
]
|
|
822 |
formdef.workflow_id = workflow.id
|
812 |
823 |
formdef.store()
|
813 |
824 |
|
814 |
825 |
data_class = formdef.data_class()
|
... | ... | |
832 |
843 |
|
833 |
844 |
formdata.just_created()
|
834 |
845 |
if i % 3 == 0:
|
835 |
|
formdata.jump_status('new')
|
|
846 |
formdata.jump_status('st1')
|
836 |
847 |
else:
|
837 |
848 |
evo = Evolution()
|
838 |
849 |
evo.who = admin_user.id
|
839 |
850 |
evo.time = time.localtime()
|
840 |
|
evo.status = 'wf-%s' % 'finished'
|
|
851 |
evo.status = 'wf-%s' % 'st2'
|
841 |
852 |
formdata.evolution.append(evo)
|
842 |
853 |
formdata.status = evo.status
|
843 |
854 |
formdata.store()
|
... | ... | |
862 |
873 |
assert 'email' in resp.json[1]['evolution'][1]['who']
|
863 |
874 |
assert 'NameID' in resp.json[1]['evolution'][1]['who']
|
864 |
875 |
assert 'name' in resp.json[1]['evolution'][1]['who']
|
|
876 |
assert resp.json[0]['workflow']['status'] == {'id': 'st2', 'name': 'Status2'}
|
|
877 |
assert resp.json[0]['workflow']['real_status'] == {'id': 'st2', 'name': 'Status2'}
|
|
878 |
assert resp.json[2]['workflow']['status'] == {'id': 'st1', 'name': 'Status1'}
|
|
879 |
assert resp.json[2]['workflow']['real_status'] == {'id': 'st1', 'name': 'Status1'}
|
865 |
880 |
|
866 |
881 |
# check access is granted event if there is no user
|
867 |
882 |
resp = get_app(pub).get(sign_uri('/api/forms/test/list?anonymise&full=on'))
|
... | ... | |
877 |
892 |
assert 'status' in resp.json[0]['evolution'][0]
|
878 |
893 |
assert 'who' not in resp.json[0]['evolution'][0]
|
879 |
894 |
assert 'time' in resp.json[0]['evolution'][0]
|
|
895 |
assert resp.json[0]['workflow']['status'] == {'id': 'st2', 'name': 'Status2'}
|
|
896 |
assert resp.json[0]['workflow']['real_status'] == {'id': 'st2', 'name': 'Status2'}
|
|
897 |
assert resp.json[2]['workflow']['status'] == {'id': 'st1', 'name': 'Status1'}
|
|
898 |
assert resp.json[2]['workflow']['real_status'] == {'id': 'st1', 'name': 'Status1'}
|
|
899 |
|
880 |
900 |
# check anonymise is enforced on detail view
|
881 |
901 |
resp = get_app(pub).get(sign_uri('/api/forms/test/%s/?anonymise' % resp.json[1]['id']))
|
882 |
902 |
assert 'receipt_time' in resp.json
|
... | ... | |
907 |
927 |
local_user.roles = [role.id]
|
908 |
928 |
local_user.store()
|
909 |
929 |
|
|
930 |
Workflow.wipe()
|
|
931 |
workflow = Workflow()
|
|
932 |
workflow.add_status('Status1', 'st1')
|
|
933 |
workflow.add_status('Status2', 'st2')
|
|
934 |
workflow.possible_status[-1].visibility = [role.id]
|
|
935 |
workflow.store()
|
|
936 |
|
910 |
937 |
FormDef.wipe()
|
911 |
938 |
formdef = FormDef()
|
912 |
939 |
formdef.name = 'test'
|
... | ... | |
915 |
942 |
fields.StringField(id='1', label='foobar', varname='foobar'),
|
916 |
943 |
fields.StringField(id='2', label='foobar2', varname='foobar2', anonymise=False),
|
917 |
944 |
]
|
|
945 |
formdef.workflow_id = workflow.id
|
918 |
946 |
formdef.store()
|
919 |
947 |
|
920 |
948 |
data_class = formdef.data_class()
|
921 |
949 |
data_class.wipe()
|
922 |
950 |
|
923 |
|
for _i in range(10):
|
|
951 |
for i in range(10):
|
924 |
952 |
formdata = data_class()
|
925 |
953 |
formdata.data = {'1': 'FOO BAR1', '2': 'FOO BAR 2'}
|
926 |
954 |
formdata.user_id = local_user.id
|
927 |
955 |
formdata.just_created()
|
|
956 |
if i % 3 == 0:
|
|
957 |
formdata.jump_status('st1')
|
|
958 |
else:
|
|
959 |
formdata.jump_status('st2')
|
928 |
960 |
formdata.store()
|
929 |
961 |
|
930 |
962 |
# check normal API behaviour: get all data
|
... | ... | |
958 |
990 |
assert resp.json[0]['fields']['foobar'] == 'FOO BAR1'
|
959 |
991 |
assert resp.json[0]['fields']['foobar2'] == 'FOO BAR 2'
|
960 |
992 |
assert resp.json[0].get('user')
|
|
993 |
assert resp.json[0]['workflow']['status'] == {'id': 'st1', 'name': 'Status1'}
|
|
994 |
assert resp.json[0]['workflow']['real_status'] == {'id': 'st1', 'name': 'Status1'}
|
|
995 |
assert resp.json[1]['workflow']['status'] == {'id': 'st2', 'name': 'Status2'}
|
|
996 |
assert resp.json[1]['workflow']['real_status'] == {'id': 'st2', 'name': 'Status2'}
|
961 |
997 |
|
962 |
998 |
# get a single formdata
|
963 |
999 |
resp = get_url('/api/forms/test/%s/' % formdata.id)
|
... | ... | |
972 |
1008 |
assert 'foobar' not in resp.json[0]['fields']
|
973 |
1009 |
assert resp.json[0]['fields']['foobar2'] == 'FOO BAR 2'
|
974 |
1010 |
assert not resp.json[0].get('user')
|
|
1011 |
assert resp.json[0]['workflow']['status'] == {'id': 'st1', 'name': 'Status1'}
|
|
1012 |
assert resp.json[0]['workflow']['real_status'] == {'id': 'st1', 'name': 'Status1'}
|
|
1013 |
assert resp.json[1]['workflow']['status'] == {'id': 'st2', 'name': 'Status2'}
|
|
1014 |
assert resp.json[1]['workflow']['real_status'] == {'id': 'st2', 'name': 'Status2'}
|
975 |
1015 |
|
976 |
1016 |
# get a single formdata
|
977 |
1017 |
resp = get_url('/api/forms/test/%s/' % formdata.id)
|