0002-misc-faster-tests.patch
tests/backoffice_pages/test_columns.py | ||
---|---|---|
5 | 5 |
import pytest |
6 | 6 | |
7 | 7 |
from wcs import fields |
8 |
from wcs.admin.settings import UserFieldsFormDef |
|
8 | 9 |
from wcs.blocks import BlockDef |
9 | 10 |
from wcs.carddef import CardDef |
10 | 11 |
from wcs.formdef import FormDef |
... | ... | |
12 | 13 |
from wcs.qommon.upload_storage import PicklableUpload |
13 | 14 | |
14 | 15 |
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, login |
15 |
from .test_all import create_environment, create_superuser, create_user
|
|
16 |
from .test_all import create_superuser
|
|
16 | 17 | |
17 | 18 | |
18 | 19 |
def pytest_generate_tests(metafunc): |
... | ... | |
45 | 46 | |
46 | 47 | |
47 | 48 |
def test_backoffice_columns(pub): |
49 |
pub.user_class.wipe() |
|
48 | 50 |
create_superuser(pub) |
49 |
create_environment(pub) |
|
51 |
pub.role_class.wipe() |
|
52 |
role = pub.role_class(name='test') |
|
53 |
role.store() |
|
54 | ||
55 |
FormDef.wipe() |
|
56 |
formdef = FormDef() |
|
57 |
formdef.name = 'form-title' |
|
58 |
formdef.geolocations = {'base': 'Geolocation'} |
|
59 |
formdef.fields = [ |
|
60 |
fields.StringField(id='1', label='1st field', type='string', display_locations=['listings']), |
|
61 |
] |
|
62 |
formdef.workflow_roles = {'_receiver': role.id} |
|
63 |
formdef.store() |
|
64 | ||
65 |
data_class = formdef.data_class() |
|
66 |
data_class.wipe() |
|
67 | ||
68 |
formdata = data_class() |
|
69 |
formdata.data = {'1': 'Foo Bar'} |
|
70 |
formdata.just_created() |
|
71 |
formdata.jump_status('new') |
|
72 |
formdata.store() |
|
73 | ||
50 | 74 |
app = login(get_app(pub)) |
51 | 75 |
resp = app.get('/backoffice/management/form-title/') |
52 |
assert resp.text.count('</th>') == 8 # six columns
|
|
76 |
assert resp.text.count('</th>') == 7 # five columns
|
|
53 | 77 |
resp.forms['listing-settings']['1'].checked = False |
54 | 78 |
assert 'submission_channel' not in resp.forms['listing-settings'].fields |
55 | 79 |
assert 'last_update_time' in resp.forms['listing-settings'].fields |
56 | 80 |
resp = resp.forms['listing-settings'].submit() |
57 |
assert resp.text.count('</th>') == 7 # fixe columns
|
|
58 |
assert resp.text.count('data-link') == 17 # 17 rows
|
|
81 |
assert resp.text.count('</th>') == 6 # fixe columns
|
|
82 |
assert resp.text.count('data-link') == 1 # 1 rows
|
|
59 | 83 |
assert resp.text.count('FOO BAR') == 0 # no field 1 column |
60 | 84 | |
61 | 85 |
# change column order |
62 | 86 |
assert ( |
63 | 87 |
resp.forms['listing-settings']['columns-order'].value |
64 |
== 'id,time,last_update_time,user-label,2,status,1,3,anonymised'
|
|
88 |
== 'id,time,last_update_time,user-label,status,1,anonymised'
|
|
65 | 89 |
) |
66 | 90 |
resp.forms['listing-settings'][ |
67 | 91 |
'columns-order' |
68 |
].value = 'user-label,id,time,last_update_time,2,status,1,3,anonymised'
|
|
92 |
].value = 'user-label,id,time,last_update_time,status,1,anonymised'
|
|
69 | 93 |
resp = resp.forms['listing-settings'].submit() |
70 | 94 |
assert resp.text.find('<span>User Label</span>') < resp.text.find('<span>Number</span>') |
71 | 95 | |
72 | 96 | |
73 | 97 |
def test_backoffice_channel_column(pub): |
98 |
pub.user_class.wipe() |
|
99 |
create_superuser(pub) |
|
100 |
pub.role_class.wipe() |
|
101 |
role = pub.role_class(name='test') |
|
102 |
role.store() |
|
103 | ||
74 | 104 |
if not pub.site_options.has_section('variables'): |
75 | 105 |
pub.site_options.add_section('variables') |
76 | 106 |
pub.site_options.set('variables', 'welco_url', 'xxx') |
77 | 107 |
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd: |
78 | 108 |
pub.site_options.write(fd) |
79 | 109 | |
80 |
create_superuser(pub) |
|
81 |
create_environment(pub) |
|
110 |
FormDef.wipe() |
|
111 |
formdef = FormDef() |
|
112 |
formdef.name = 'form-title' |
|
113 |
formdef.geolocations = {'base': 'Geolocation'} |
|
114 |
formdef.fields = [] |
|
115 |
formdef.workflow_roles = {'_receiver': role.id} |
|
116 |
formdef.store() |
|
117 | ||
118 |
data_class = formdef.data_class() |
|
119 |
data_class.wipe() |
|
120 | ||
121 |
formdata = data_class() |
|
122 |
formdata.data = {} |
|
123 |
formdata.just_created() |
|
124 |
formdata.jump_status('new') |
|
125 |
formdata.store() |
|
126 | ||
82 | 127 |
app = login(get_app(pub)) |
83 | 128 |
resp = app.get('/backoffice/management/form-title/') |
84 |
assert resp.text.count('</th>') == 8 # six columns
|
|
129 |
assert resp.text.count('</th>') == 6 # four columns
|
|
85 | 130 |
resp.forms['listing-settings']['submission_channel'].checked = True |
86 | 131 |
resp = resp.forms['listing-settings'].submit() |
87 |
assert resp.text.count('</th>') == 9 # seven columns
|
|
88 |
assert resp.text.count('data-link') == 17 # 17 rows
|
|
89 |
assert resp.text.count('<td>Web</td>') == 17
|
|
132 |
assert resp.text.count('</th>') == 7 # five columns
|
|
133 |
assert resp.text.count('data-link') == 1 # 1 row
|
|
134 |
assert resp.text.count('<td>Web</td>') == 1 |
|
90 | 135 | |
91 | 136 | |
92 | 137 |
def test_backoffice_submission_agent_column(pub): |
93 |
user = create_user(pub) |
|
94 |
create_environment(pub) |
|
138 |
pub.user_class.wipe() |
|
139 |
create_superuser(pub) |
|
140 |
pub.role_class.wipe() |
|
141 |
role = pub.role_class(name='test') |
|
142 |
role.store() |
|
95 | 143 | |
96 | 144 |
agent = pub.user_class(name='agent') |
97 | 145 |
agent.store() |
98 | 146 | |
147 |
FormDef.wipe() |
|
148 |
formdef = FormDef() |
|
149 |
formdef.name = 'form-title' |
|
150 |
formdef.geolocations = {'base': 'Geolocation'} |
|
151 |
formdef.fields = [] |
|
152 |
formdef.workflow_roles = {'_receiver': role.id} |
|
153 |
formdef.store() |
|
154 | ||
155 |
data_class = formdef.data_class() |
|
156 |
data_class.wipe() |
|
157 | ||
158 |
formdata = data_class() |
|
159 |
formdata.data = {} |
|
160 |
formdata.just_created() |
|
161 |
formdata.jump_status('new') |
|
162 |
formdata.store() |
|
163 | ||
99 | 164 |
app = login(get_app(pub)) |
100 | 165 |
resp = app.get('/backoffice/management/form-title/') |
101 | 166 |
assert 'submission_agent' not in resp.forms['listing-settings'].fields |
102 | 167 | |
103 |
formdef = FormDef.get_by_urlname('form-title') |
|
104 |
formdef.backoffice_submission_roles = user.roles |
|
168 |
formdef.backoffice_submission_roles = [role] |
|
105 | 169 |
formdef.store() |
170 | ||
106 | 171 |
resp = app.get('/backoffice/management/form-title/') |
107 |
assert resp.text.count('</th>') == 8 # six columns
|
|
172 |
assert resp.text.count('</th>') == 6 # four columns
|
|
108 | 173 |
resp.forms['listing-settings']['submission_agent'].checked = True |
109 | 174 |
resp = resp.forms['listing-settings'].submit() |
110 |
assert resp.text.count('</th>') == 9 # seven columns
|
|
111 |
assert resp.text.count('data-link') == 17 # 17 rows
|
|
175 |
assert resp.text.count('</th>') == 7 # five columns
|
|
176 |
assert resp.text.count('data-link') == 1 # 1 row
|
|
112 | 177 |
assert '>agent<' not in resp.text |
113 | 178 |
resp = resp.click('Export a Spreadsheet') |
114 | 179 |
resp.form['format'] = 'csv' |
115 | 180 |
resp = resp.form.submit('submit') |
116 |
assert len(resp.text.splitlines()) == 18 # 17 + header line
|
|
181 |
assert len(resp.text.splitlines()) == 2 # 1 + header line
|
|
117 | 182 |
assert ',"agent",' not in resp.text |
118 | 183 | |
119 | 184 |
for formdata in formdef.data_class().select(): |
... | ... | |
123 | 188 |
resp = app.get('/backoffice/management/form-title/') |
124 | 189 |
resp.forms['listing-settings']['submission_agent'].checked = True |
125 | 190 |
resp = resp.forms['listing-settings'].submit() |
126 |
assert resp.text.count('>agent<') == 17
|
|
191 |
assert resp.text.count('>agent<') == 1 |
|
127 | 192 | |
128 | 193 |
resp = resp.click('Export a Spreadsheet') |
129 | 194 |
resp.form['format'] = 'csv' |
130 | 195 |
resp = resp.form.submit('submit') |
131 |
assert len(resp.text.splitlines()) == 18 # 17 + header line
|
|
132 |
assert resp.text.count(',"agent"') == 17
|
|
196 |
assert len(resp.text.splitlines()) == 2 # 1 + header line
|
|
197 |
assert resp.text.count(',"agent"') == 1 |
|
133 | 198 | |
134 | 199 | |
135 | 200 |
def test_backoffice_image_column(pub): |
201 |
pub.user_class.wipe() |
|
136 | 202 |
create_superuser(pub) |
137 |
create_environment(pub) |
|
138 |
formdef = FormDef.get_by_urlname('form-title') |
|
139 |
formdef.fields.append( |
|
203 |
pub.role_class.wipe() |
|
204 |
role = pub.role_class(name='test') |
|
205 |
role.store() |
|
206 | ||
207 |
FormDef.wipe() |
|
208 |
formdef = FormDef() |
|
209 |
formdef.name = 'form-title' |
|
210 |
formdef.geolocations = {'base': 'Geolocation'} |
|
211 |
formdef.fields = [ |
|
140 | 212 |
fields.FileField( |
141 | 213 |
id='4', label='file field', type='file', display_locations=['validation', 'summary', 'listings'] |
142 | 214 |
) |
143 |
) |
|
215 |
] |
|
216 |
formdef.workflow_roles = {'_receiver': role.id} |
|
144 | 217 |
formdef.store() |
145 | 218 | |
146 | 219 |
upload = PicklableUpload('test.jpeg', 'image/jpeg') |
147 | 220 |
with open(os.path.join(os.path.dirname(__file__), '..', 'image-with-gps-data.jpeg'), 'rb') as fd: |
148 | 221 |
upload.receive([fd.read()]) |
149 |
for formdata in formdef.data_class().select(lambda x: x.status == 'wf-new'): |
|
150 |
formdata.data['4'] = upload |
|
151 |
formdata.store() |
|
222 | ||
223 |
data_class = formdef.data_class() |
|
224 |
data_class.wipe() |
|
225 | ||
226 |
formdata = data_class() |
|
227 |
formdata.data = {'4': upload} |
|
228 |
formdata.just_created() |
|
229 |
formdata.jump_status('new') |
|
230 |
formdata.store() |
|
231 | ||
152 | 232 |
app = login(get_app(pub)) |
153 | 233 |
resp = app.get('/backoffice/management/form-title/') |
154 | 234 |
assert 'download?f=4&thumbnail=1' not in resp.text |
155 | 235 | |
156 | 236 | |
157 | 237 |
def test_backoffice_file_column(pub): |
238 |
pub.user_class.wipe() |
|
158 | 239 |
create_superuser(pub) |
159 |
create_environment(pub) |
|
160 |
formdef = FormDef.get_by_urlname('form-title') |
|
161 |
formdef.fields.append( |
|
240 |
pub.role_class.wipe() |
|
241 |
role = pub.role_class(name='test') |
|
242 |
role.store() |
|
243 | ||
244 |
FormDef.wipe() |
|
245 |
formdef = FormDef() |
|
246 |
formdef.name = 'form-title' |
|
247 |
formdef.geolocations = {'base': 'Geolocation'} |
|
248 |
formdef.fields = [ |
|
162 | 249 |
fields.FileField( |
163 | 250 |
id='4', label='file field', type='file', display_locations=['validation', 'summary', 'listings'] |
164 | 251 |
) |
165 |
) |
|
252 |
] |
|
253 |
formdef.workflow_roles = {'_receiver': role.id} |
|
166 | 254 |
formdef.store() |
167 | 255 | |
168 | 256 |
upload = PicklableUpload('a filename that is too long "and" will be ellipsised.txt', 'text/plain') |
169 | 257 |
upload.receive([b'text']) |
170 |
for formdata in formdef.data_class().select(lambda x: x.status == 'wf-new'): |
|
171 |
formdata.data['4'] = upload |
|
172 |
formdata.store() |
|
258 | ||
259 |
data_class = formdef.data_class() |
|
260 |
data_class.wipe() |
|
261 | ||
262 |
formdata = data_class() |
|
263 |
formdata.data = {'4': upload} |
|
264 |
formdata.just_created() |
|
265 |
formdata.jump_status('new') |
|
266 |
formdata.store() |
|
267 | ||
173 | 268 |
app = login(get_app(pub)) |
174 | 269 |
resp = app.get('/backoffice/management/form-title/') |
175 | 270 |
assert 'title="a filename that is too long "and" will be ellipsised.txt"' in resp |
... | ... | |
177 | 272 | |
178 | 273 | |
179 | 274 |
def test_backoffice_user_columns(pub): |
275 |
pub.user_class.wipe() |
|
180 | 276 |
create_superuser(pub) |
181 |
create_environment(pub)
|
|
182 | ||
183 |
from wcs.admin.settings import UserFieldsFormDef
|
|
277 |
pub.role_class.wipe()
|
|
278 |
role = pub.role_class(name='test') |
|
279 |
role.store()
|
|
184 | 280 | |
185 | 281 |
user_formdef = UserFieldsFormDef(pub) |
186 | 282 |
user_formdef.fields.append(fields.StringField(id='_first_name', label='name', type='string')) |
... | ... | |
198 | 294 |
user2.set_attributes_from_formdata(user2.form_data) |
199 | 295 |
user2.store() |
200 | 296 | |
201 |
formdef = FormDef.get_by_urlname('form-title') |
|
202 |
for i, formdata in enumerate(formdef.data_class().select()): |
|
297 |
FormDef.wipe() |
|
298 |
formdef = FormDef() |
|
299 |
formdef.name = 'form-title' |
|
300 |
formdef.geolocations = {'base': 'Geolocation'} |
|
301 |
formdef.fields = [] |
|
302 |
formdef.workflow_roles = {'_receiver': role.id} |
|
303 |
formdef.store() |
|
304 | ||
305 |
data_class = formdef.data_class() |
|
306 |
data_class.wipe() |
|
307 | ||
308 |
for i in range(0, 2): |
|
309 |
formdata = data_class() |
|
310 |
formdata.data = {} |
|
203 | 311 |
formdata.user_id = user1.id if bool(i % 2) else user2.id |
312 |
formdata.just_created() |
|
313 |
formdata.jump_status('new') |
|
204 | 314 |
formdata.store() |
205 | 315 | |
206 | 316 |
app = login(get_app(pub)) |
207 | 317 |
resp = app.get('/backoffice/management/form-title/') |
208 |
assert resp.text.count('</th>') == 8 # six columns
|
|
318 |
assert resp.text.count('</th>') == 6 # four columns
|
|
209 | 319 | |
210 | 320 |
if not pub.is_using_postgresql(): |
211 | 321 |
# no support for relation columns unless using SQL |
... | ... | |
213 | 323 |
return |
214 | 324 |
resp.forms['listing-settings']['user-label$3'].checked = True |
215 | 325 |
resp = resp.forms['listing-settings'].submit() |
216 |
assert resp.text.count('</th>') == 9
|
|
326 |
assert resp.text.count('</th>') == 7
|
|
217 | 327 |
assert '<td>nono</td' in resp |
218 | 328 | |
219 | 329 | |
220 | 330 |
def test_backoffice_card_field_columns(pub): |
221 |
user = create_superuser(pub) |
|
222 |
create_environment(pub) |
|
331 |
pub.user_class.wipe() |
|
332 |
create_superuser(pub) |
|
333 |
pub.role_class.wipe() |
|
334 |
role = pub.role_class(name='test') |
|
335 |
role.store() |
|
223 | 336 | |
224 | 337 |
datasource = {'type': 'formula', 'value': repr([('A', 'aa'), ('B', 'bb'), ('C', 'cc')])} |
225 | 338 | |
... | ... | |
233 | 346 |
fields.BoolField(id='3', label='Bool', type='bool'), |
234 | 347 |
fields.ItemField(id='4', label='Item', type='item', data_source=datasource), |
235 | 348 |
] |
236 |
carddef.backoffice_submission_roles = user.roles |
|
237 |
carddef.workflow_roles = {'_editor': user.roles[0]} |
|
238 | 349 |
carddef.digest_templates = {'default': 'card {{ form_var_foo }}'} |
239 | 350 |
carddef.store() |
240 | 351 |
carddef.data_class().wipe() |
... | ... | |
249 | 360 |
} |
250 | 361 |
card.store() |
251 | 362 | |
252 |
formdef = FormDef.get_by_urlname('form-title') |
|
363 |
FormDef.wipe() |
|
364 |
formdef = FormDef() |
|
365 |
formdef.name = 'form-title' |
|
253 | 366 |
formdef.geolocations = {'base': 'Geolocation'} |
254 |
formdef.fields.append(
|
|
367 |
formdef.fields = [
|
|
255 | 368 |
fields.ItemField( |
256 | 369 |
id='4', label='card field', type='item', data_source={'type': 'carddef:foo', 'value': ''} |
257 | 370 |
) |
258 |
) |
|
371 |
] |
|
372 |
formdef.workflow_roles = {'_receiver': role.id} |
|
259 | 373 |
formdef.store() |
260 | 374 | |
261 |
for formdata in formdef.data_class().select(lambda x: x.status == 'wf-new'): |
|
262 |
formdata.data['4'] = str(card.id) |
|
263 |
formdata.data['4_display'] = formdef.fields[-1].store_display_value(formdata.data, '4') |
|
264 |
formdata.data['4_structured'] = formdef.fields[-1].store_structured_value(formdata.data, '4') |
|
265 |
formdata.geolocations = {'base': {'lat': 48.83, 'lon': 2.32}} |
|
266 |
formdata.store() |
|
375 |
data_class = formdef.data_class() |
|
376 |
data_class.wipe() |
|
377 | ||
378 |
formdata = data_class() |
|
379 |
formdata.data = { |
|
380 |
'4': str(card.id), |
|
381 |
} |
|
382 |
formdata.data['4_display'] = formdef.fields[-1].store_display_value(formdata.data, '4') |
|
383 |
formdata.data['4_structured'] = formdef.fields[-1].store_structured_value(formdata.data, '4') |
|
384 |
formdata.geolocations = {'base': {'lat': 48.83, 'lon': 2.32}} |
|
385 |
formdata.just_created() |
|
386 |
formdata.jump_status('new') |
|
387 |
formdata.store() |
|
267 | 388 | |
268 | 389 |
app = login(get_app(pub)) |
269 | 390 |
resp = app.get('/backoffice/management/form-title/') |
270 |
assert resp.text.count('</th>') == 8 # six columns
|
|
391 |
assert resp.text.count('</th>') == 6 # four columns
|
|
271 | 392 |
if not pub.is_using_postgresql(): |
272 | 393 |
# no support for relation columns unless using SQL |
273 | 394 |
assert '4$1' not in resp.forms['listing-settings'].fields |
... | ... | |
278 | 399 |
resp.forms['listing-settings']['4$3'].checked = True |
279 | 400 |
resp.forms['listing-settings']['4$4'].checked = True |
280 | 401 |
resp = resp.forms['listing-settings'].submit() |
281 |
assert resp.text.count('</th>') == 12
|
|
282 |
assert resp.text.count('data-link') == 17 # 17 rows
|
|
283 |
assert resp.text.count('<td>plop</td>') == 17
|
|
284 |
assert resp.text.count('<td>2020-04-24</td>') == 17
|
|
285 |
assert resp.text.count('<td>Yes</td>') == 17
|
|
286 |
assert resp.text.count('<td>aa</td>') == 17
|
|
402 |
assert resp.text.count('</th>') == 10
|
|
403 |
assert resp.text.count('data-link') == 1 # 1 row
|
|
404 |
assert resp.text.count('<td>plop</td>') == 1 |
|
405 |
assert resp.text.count('<td>2020-04-24</td>') == 1 |
|
406 |
assert resp.text.count('<td>Yes</td>') == 1 |
|
407 |
assert resp.text.count('<td>aa</td>') == 1 |
|
287 | 408 | |
288 | 409 |
resp_csv = resp.click('Export a Spreadsheet') |
289 | 410 |
resp_csv.form['format'] = 'csv' |
... | ... | |
302 | 423 | |
303 | 424 | |
304 | 425 |
def test_backoffice_block_columns(pub): |
305 |
create_environment(pub)
|
|
426 |
pub.user_class.wipe()
|
|
306 | 427 |
create_superuser(pub) |
428 |
pub.role_class.wipe() |
|
429 |
role = pub.role_class(name='test') |
|
430 |
role.store() |
|
307 | 431 | |
308 | 432 |
BlockDef.wipe() |
309 | 433 |
block = BlockDef() |
... | ... | |
313 | 437 |
] |
314 | 438 |
block.store() |
315 | 439 | |
316 |
formdef = FormDef.get_by_urlname('form-title') |
|
317 |
formdef.fields.append( |
|
440 |
FormDef.wipe() |
|
441 |
formdef = FormDef() |
|
442 |
formdef.name = 'form-title' |
|
443 |
formdef.fields = [ |
|
318 | 444 |
fields.BlockField(id='8', label='Block', type='block:foobar', varname='data', max_items=3), |
319 |
) |
|
445 |
] |
|
446 |
formdef.workflow_roles = {'_receiver': role.id} |
|
320 | 447 |
formdef.store() |
321 | 448 | |
322 |
for formdata in formdef.data_class().select(lambda x: x.status == 'wf-new'): |
|
323 |
formdata.data['8'] = { |
|
324 |
'data': [{'123': 'blah'}], |
|
325 |
'schema': {'123': 'string'}, |
|
326 |
} |
|
327 |
formdata.data['8_display'] = 'blah' |
|
328 |
formdata.store() |
|
329 | ||
330 | 449 |
app = login(get_app(pub)) |
331 | 450 |
resp = app.get('/backoffice/management/form-title/') |
332 | 451 |
# check Block / Test is not part of the possible columns |
... | ... | |
335 | 454 |
'Created', |
336 | 455 |
'Last Modified', |
337 | 456 |
'User Label', |
338 |
'1st field', |
|
339 |
'2nd field', |
|
340 | 457 |
'Status', |
341 |
'3rd field', |
|
342 | 458 |
'Block', |
343 | 459 |
'Anonymised', |
344 | 460 |
] |
tests/backoffice_pages/test_filters.py | ||
---|---|---|
95 | 95 | |
96 | 96 | |
97 | 97 |
def test_backoffice_default_filter(pub): |
98 |
pub.user_class.wipe() |
|
98 | 99 |
create_superuser(pub) |
99 |
create_environment(pub) |
|
100 |
pub.role_class.wipe() |
|
101 |
role = pub.role_class(name='test') |
|
102 |
role.store() |
|
103 | ||
104 |
FormDef.wipe() |
|
105 |
formdef = FormDef() |
|
106 |
formdef.name = 'form-title' |
|
107 |
formdef.fields = [ |
|
108 |
fields.ItemField( |
|
109 |
id='2', |
|
110 |
label='2nd field', |
|
111 |
type='item', |
|
112 |
items=['foo', 'bar', 'baz'], |
|
113 |
display_locations=['validation', 'summary', 'listings'], |
|
114 |
), |
|
115 |
] |
|
116 |
formdef.workflow_roles = {'_receiver': role.id} |
|
117 |
formdef.store() |
|
118 | ||
100 | 119 |
app = login(get_app(pub)) |
101 | 120 |
resp = app.get('/backoffice/management/form-title/') |
102 | 121 |
assert 'filter-2-value' not in resp.forms['listing-settings'].fields |
103 | 122 | |
104 | 123 |
formdef = FormDef.get_by_urlname('form-title') |
105 |
formdef.fields[1].in_filters = True
|
|
124 |
formdef.fields[0].in_filters = True
|
|
106 | 125 |
formdef.store() |
107 | 126 |
resp = app.get('/backoffice/management/form-title/') |
108 | 127 |
assert 'filter-2-value' in resp.forms['listing-settings'].fields |
... | ... | |
115 | 134 |
resp = app.get('/backoffice/management/form-title/') |
116 | 135 |
assert 'filter-4-value' not in resp.forms['listing-settings'].fields |
117 | 136 | |
118 |
formdef.fields[-1].in_filters = True
|
|
137 |
formdef.fields[1].in_filters = True |
|
119 | 138 |
formdef.store() |
120 | 139 |
resp = app.get('/backoffice/management/form-title/') |
121 | 140 |
assert 'filter-4-value' in resp.forms['listing-settings'].fields |
122 | 141 | |
123 | 142 | |
124 | 143 |
def test_backoffice_bool_filter(pub): |
144 |
pub.user_class.wipe() |
|
125 | 145 |
create_superuser(pub) |
126 |
create_environment(pub) |
|
127 |
formdef = FormDef.get_by_urlname('form-title') |
|
128 |
formdef.fields.append( |
|
146 |
pub.role_class.wipe() |
|
147 |
role = pub.role_class(name='test') |
|
148 |
role.store() |
|
149 | ||
150 |
FormDef.wipe() |
|
151 |
formdef = FormDef() |
|
152 |
formdef.name = 'form-title' |
|
153 |
formdef.fields = [ |
|
129 | 154 |
fields.BoolField( |
130 | 155 |
id='4', label='4th field', type='bool', display_locations=['validation', 'summary', 'listings'] |
131 | 156 |
) |
132 |
) |
|
157 |
] |
|
158 |
formdef.workflow_roles = {'_receiver': role.id} |
|
133 | 159 |
formdef.store() |
134 | 160 | |
135 |
for i, formdata in enumerate(formdef.data_class().select()): |
|
136 |
formdata.data['4'] = bool(i % 2) |
|
161 |
data_class = formdef.data_class() |
|
162 |
data_class.wipe() |
|
163 | ||
164 |
for i in range(0, 2): |
|
165 |
formdata = data_class() |
|
166 |
formdata.data = {'4': bool(i % 2)} |
|
167 |
formdata.just_created() |
|
168 |
formdata.jump_status('new') |
|
137 | 169 |
formdata.store() |
138 | 170 | |
139 | 171 |
app = login(get_app(pub)) |
... | ... | |
155 | 187 | |
156 | 188 | |
157 | 189 |
def test_backoffice_item_filter(pub): |
190 |
pub.user_class.wipe() |
|
158 | 191 |
create_superuser(pub) |
159 |
create_environment(pub) |
|
160 |
formdef = FormDef.get_by_urlname('form-title') |
|
161 |
formdef.fields.append( |
|
192 |
pub.role_class.wipe() |
|
193 |
role = pub.role_class(name='test') |
|
194 |
role.store() |
|
195 | ||
196 |
FormDef.wipe() |
|
197 |
formdef = FormDef() |
|
198 |
formdef.name = 'form-title' |
|
199 |
formdef.fields = [ |
|
162 | 200 |
fields.ItemField( |
163 | 201 |
id='4', |
164 | 202 |
label='4th field', |
... | ... | |
166 | 204 |
items=['â', 'b', 'c', 'd'], |
167 | 205 |
display_locations=['validation', 'summary', 'listings'], |
168 | 206 |
) |
169 |
) |
|
207 |
] |
|
208 |
formdef.workflow_roles = {'_receiver': role.id} |
|
170 | 209 |
formdef.store() |
171 | 210 | |
172 |
for i, formdata in enumerate(formdef.data_class().select()): |
|
211 |
data_class = formdef.data_class() |
|
212 |
data_class.wipe() |
|
213 | ||
214 |
for i in range(0, 12): |
|
215 |
formdata = data_class() |
|
216 |
formdata.data = {} |
|
173 | 217 |
if i % 4 == 0: |
174 | 218 |
formdata.data['4'] = 'â' |
175 | 219 |
formdata.data['4_display'] = 'â' |
... | ... | |
182 | 226 |
else: |
183 | 227 |
formdata.data['4'] = '' |
184 | 228 |
formdata.data['4_display'] = '' |
229 |
formdata.just_created() |
|
230 |
if i % 3 == 0: |
|
231 |
formdata.jump_status('new') |
|
232 |
else: |
|
233 |
formdata.jump_status('finished') |
|
185 | 234 |
formdata.store() |
186 | 235 | |
187 | 236 |
app = login(get_app(pub)) |
... | ... | |
243 | 292 |
if not pub.is_using_postgresql(): |
244 | 293 |
pytest.skip('this requires SQL') |
245 | 294 |
return |
295 |
pub.user_class.wipe() |
|
246 | 296 |
create_superuser(pub) |
247 |
create_environment(pub) |
|
248 |
formdef = FormDef.get_by_urlname('form-title') |
|
249 |
formdef.fields.append( |
|
297 |
pub.role_class.wipe() |
|
298 |
role = pub.role_class(name='test') |
|
299 |
role.store() |
|
300 | ||
301 |
FormDef.wipe() |
|
302 |
formdef = FormDef() |
|
303 |
formdef.name = 'form-title' |
|
304 |
formdef.fields = [ |
|
250 | 305 |
fields.ItemField( |
251 | 306 |
id='4', |
252 | 307 |
label='4th field', |
253 | 308 |
type='item', |
254 |
items=['a', 'b', 'c', 'd'],
|
|
309 |
items=['â', 'b', 'c', 'd'],
|
|
255 | 310 |
display_locations=['validation', 'summary', 'listings'], |
256 |
) |
|
257 |
) |
|
258 |
formdef.fields.append( |
|
311 |
), |
|
259 | 312 |
fields.ItemField( |
260 | 313 |
id='5', |
261 | 314 |
label='5th field', |
262 | 315 |
type='item', |
263 | 316 |
items=['E', 'F', 'G', 'H'], |
264 | 317 |
display_locations=['validation', 'summary', 'listings'], |
265 |
) |
|
266 |
) |
|
318 |
), |
|
319 |
] |
|
320 |
formdef.workflow_roles = {'_receiver': role.id} |
|
267 | 321 |
formdef.store() |
268 | 322 | |
269 |
for i, formdata in enumerate(formdef.data_class().select()): |
|
270 |
formdata.jump_status('new') |
|
323 |
data_class = formdef.data_class() |
|
324 |
data_class.wipe() |
|
325 | ||
326 |
for i in range(0, 4): |
|
327 |
formdata = data_class() |
|
328 |
formdata.data = {} |
|
271 | 329 |
if i % 4 == 0: |
272 | 330 |
formdata.data['4'] = 'a' |
273 | 331 |
formdata.data['4_display'] = 'a' |
... | ... | |
288 | 346 |
formdata.data['4_display'] = 'b' |
289 | 347 |
formdata.data['5'] = 'F' |
290 | 348 |
formdata.data['5_display'] = 'F' |
349 |
formdata.just_created() |
|
350 |
formdata.jump_status('new') |
|
291 | 351 |
formdata.store() |
292 | 352 | |
293 | 353 |
app = login(get_app(pub)) |
... | ... | |
323 | 383 | |
324 | 384 | |
325 | 385 |
def test_backoffice_bofield_item_filter(pub): |
386 |
pub.user_class.wipe() |
|
326 | 387 |
create_superuser(pub) |
327 |
create_environment(pub) |
|
328 |
formdef = FormDef.get_by_urlname('form-title') |
|
388 |
pub.role_class.wipe() |
|
389 |
role = pub.role_class(name='test') |
|
390 |
role.store() |
|
391 | ||
329 | 392 |
workflow = Workflow.get_default_workflow() |
330 | 393 |
workflow.id = '2' |
331 | 394 |
workflow.backoffice_fields_formdef = WorkflowBackofficeFieldsFormDef(workflow) |
... | ... | |
339 | 402 |
) |
340 | 403 |
] |
341 | 404 |
workflow.store() |
405 | ||
406 |
FormDef.wipe() |
|
407 |
formdef = FormDef() |
|
408 |
formdef.name = 'form-title' |
|
409 |
formdef.fields = [] |
|
410 |
formdef.workflow_roles = {'_receiver': role.id} |
|
342 | 411 |
formdef.workflow_id = workflow.id |
343 | 412 |
formdef.store() |
344 | 413 | |
345 |
for i, formdata in enumerate(formdef.data_class().select()): |
|
414 |
data_class = formdef.data_class() |
|
415 |
data_class.wipe() |
|
416 | ||
417 |
for i in range(0, 12): |
|
418 |
formdata = data_class() |
|
419 |
formdata.data = {} |
|
346 | 420 |
if i % 4 == 0: |
347 | 421 |
formdata.data['bo0-1'] = 'â' |
348 | 422 |
formdata.data['bo0-1_display'] = 'â' |
... | ... | |
352 | 426 |
elif i % 4 == 2: |
353 | 427 |
formdata.data['bo0-1'] = 'd' |
354 | 428 |
formdata.data['bo0-1_display'] = 'd' |
429 |
formdata.just_created() |
|
430 |
if i % 3 == 0: |
|
431 |
formdata.jump_status('new') |
|
432 |
else: |
|
433 |
formdata.jump_status('finished') |
|
355 | 434 |
formdata.store() |
356 | 435 | |
357 | 436 |
app = login(get_app(pub)) |
... | ... | |
409 | 488 | |
410 | 489 | |
411 | 490 |
def test_backoffice_items_filter(pub): |
491 |
pub.user_class.wipe() |
|
412 | 492 |
create_superuser(pub) |
413 |
create_environment(pub) |
|
414 |
formdef = FormDef.get_by_urlname('form-title') |
|
415 |
formdef.fields.append( |
|
493 |
pub.role_class.wipe() |
|
494 |
role = pub.role_class(name='test') |
|
495 |
role.store() |
|
496 | ||
497 |
FormDef.wipe() |
|
498 |
formdef = FormDef() |
|
499 |
formdef.name = 'form-title' |
|
500 |
formdef.fields = [ |
|
416 | 501 |
fields.ItemsField( |
417 | 502 |
id='4', |
418 | 503 |
label='4th field', |
... | ... | |
420 | 505 |
items=['â', 'b', 'c', 'd'], |
421 | 506 |
display_locations=['validation', 'summary', 'listings'], |
422 | 507 |
) |
423 |
) |
|
508 |
] |
|
509 |
formdef.workflow_roles = {'_receiver': role.id} |
|
424 | 510 |
formdef.store() |
425 | 511 | |
426 |
for i, formdata in enumerate(formdef.data_class().select()): |
|
512 |
data_class = formdef.data_class() |
|
513 |
data_class.wipe() |
|
514 | ||
515 |
for i in range(0, 4): |
|
516 |
formdata = data_class() |
|
517 |
formdata.data = {} |
|
427 | 518 |
if i % 4 == 0: |
428 | 519 |
formdata.data['4'] = ['â', 'b'] |
429 | 520 |
formdata.data['4_display'] = 'â, b' |
... | ... | |
436 | 527 |
else: |
437 | 528 |
formdata.data['4'] = [] |
438 | 529 |
formdata.data['4_display'] = None |
530 |
formdata.just_created() |
|
531 |
formdata.jump_status('new') |
|
439 | 532 |
formdata.store() |
440 | 533 | |
441 | 534 |
app = login(get_app(pub)) |
... | ... | |
471 | 564 | |
472 | 565 | |
473 | 566 |
def test_backoffice_string_filter(pub): |
567 |
pub.user_class.wipe() |
|
474 | 568 |
create_superuser(pub) |
475 |
create_environment(pub) |
|
476 |
formdef = FormDef.get_by_urlname('form-title') |
|
477 |
formdef.fields.append( |
|
569 |
pub.role_class.wipe() |
|
570 |
role = pub.role_class(name='test') |
|
571 |
role.store() |
|
572 | ||
573 |
FormDef.wipe() |
|
574 |
formdef = FormDef() |
|
575 |
formdef.name = 'form-title' |
|
576 |
formdef.fields = [ |
|
478 | 577 |
fields.StringField( |
479 | 578 |
id='4', label='4th field', type='string', display_locations=['validation', 'summary', 'listings'] |
480 | 579 |
) |
481 |
) |
|
580 |
] |
|
581 |
formdef.workflow_roles = {'_receiver': role.id} |
|
482 | 582 |
formdef.store() |
483 | 583 | |
484 |
for i, formdata in enumerate(formdef.data_class().select()): |
|
584 |
data_class = formdef.data_class() |
|
585 |
data_class.wipe() |
|
586 | ||
587 |
for i in range(0, 2): |
|
588 |
formdata = data_class() |
|
589 |
formdata.data = {} |
|
485 | 590 |
formdata.data['4'] = 'a' if bool(i % 2) else 'b' |
591 |
formdata.just_created() |
|
592 |
formdata.jump_status('new') |
|
486 | 593 |
formdata.store() |
487 | 594 | |
488 | 595 |
app = login(get_app(pub)) |
... | ... | |
504 | 611 | |
505 | 612 | |
506 | 613 |
def test_backoffice_email_filter(pub): |
614 |
pub.user_class.wipe() |
|
507 | 615 |
create_superuser(pub) |
508 |
create_environment(pub) |
|
509 |
formdef = FormDef.get_by_urlname('form-title') |
|
510 |
formdef.fields.append( |
|
616 |
pub.role_class.wipe() |
|
617 |
role = pub.role_class(name='test') |
|
618 |
role.store() |
|
619 | ||
620 |
FormDef.wipe() |
|
621 |
formdef = FormDef() |
|
622 |
formdef.name = 'form-title' |
|
623 |
formdef.fields = [ |
|
511 | 624 |
fields.EmailField( |
512 | 625 |
id='4', label='4th field', type='email', display_locations=['validation', 'summary', 'listings'] |
513 | 626 |
) |
514 |
) |
|
627 |
] |
|
628 |
formdef.workflow_roles = {'_receiver': role.id} |
|
515 | 629 |
formdef.store() |
516 | 630 | |
517 |
for i, formdata in enumerate(formdef.data_class().select()): |
|
631 |
data_class = formdef.data_class() |
|
632 |
data_class.wipe() |
|
633 | ||
634 |
for i in range(0, 2): |
|
635 |
formdata = data_class() |
|
636 |
formdata.data = {} |
|
518 | 637 |
formdata.data['4'] = 'a@localhost' if bool(i % 2) else 'b@localhost' |
638 |
formdata.just_created() |
|
639 |
formdata.jump_status('new') |
|
519 | 640 |
formdata.store() |
520 | 641 | |
521 | 642 |
app = login(get_app(pub)) |
... | ... | |
540 | 661 |
if not pub.is_using_postgresql(): |
541 | 662 |
pytest.skip('this requires SQL') |
542 | 663 |
return |
664 |
pub.user_class.wipe() |
|
543 | 665 |
create_superuser(pub) |
544 |
create_environment(pub) |
|
545 |
formdef = FormDef.get_by_urlname('form-title') |
|
546 |
formdef.fields.append( |
|
666 |
pub.role_class.wipe() |
|
667 |
role = pub.role_class(name='test') |
|
668 |
role.store() |
|
669 | ||
670 |
FormDef.wipe() |
|
671 |
formdef = FormDef() |
|
672 |
formdef.name = 'form-title' |
|
673 |
formdef.fields = [ |
|
547 | 674 |
fields.DateField( |
548 | 675 |
id='4', label='4th field', type='date', display_locations=['validation', 'summary', 'listings'] |
549 | 676 |
) |
550 |
) |
|
677 |
] |
|
678 |
formdef.workflow_roles = {'_receiver': role.id} |
|
551 | 679 |
formdef.store() |
552 | 680 | |
553 |
for i, formdata in enumerate(formdef.data_class().select()): |
|
681 |
data_class = formdef.data_class() |
|
682 |
data_class.wipe() |
|
683 | ||
684 |
for i in range(0, 2): |
|
685 |
formdata = data_class() |
|
686 |
formdata.data = {} |
|
554 | 687 |
formdata.data['4'] = time.strptime('2020-04-24' if bool(i % 2) else '2015-05-12', '%Y-%m-%d') |
688 |
formdata.just_created() |
|
689 |
formdata.jump_status('new') |
|
555 | 690 |
formdata.store() |
556 | 691 | |
557 | 692 |
app = login(get_app(pub)) |
... | ... | |
579 | 714 | |
580 | 715 | |
581 | 716 |
def test_backoffice_user_filter(pub): |
717 |
pub.user_class.wipe() |
|
582 | 718 |
create_superuser(pub) |
583 |
create_environment(pub) |
|
584 |
formdef = FormDef.get_by_urlname('form-title') |
|
719 |
pub.role_class.wipe() |
|
720 |
role = pub.role_class(name='test') |
|
721 |
role.store() |
|
722 | ||
723 |
FormDef.wipe() |
|
724 |
formdef = FormDef() |
|
725 |
formdef.name = 'form-title' |
|
726 |
formdef.fields = [] |
|
727 |
formdef.workflow_roles = {'_receiver': role.id} |
|
585 | 728 |
formdef.store() |
586 | 729 | |
587 | 730 |
user1 = pub.user_class(name='userA') |
... | ... | |
589 | 732 |
user2 = pub.user_class(name='userB') |
590 | 733 |
user2.store() |
591 | 734 | |
592 |
for i, formdata in enumerate(formdef.data_class().select()): |
|
735 |
data_class = formdef.data_class() |
|
736 |
data_class.wipe() |
|
737 | ||
738 |
for i in range(0, 2): |
|
739 |
formdata = data_class() |
|
740 |
formdata.data = {} |
|
593 | 741 |
formdata.user_id = user1.id if bool(i % 2) else user2.id |
742 |
formdata.just_created() |
|
743 |
formdata.jump_status('new') |
|
594 | 744 |
formdata.store() |
595 | 745 | |
596 | 746 |
app = login(get_app(pub)) |
... | ... | |
630 | 780 |
def test_backoffice_submission_agent_filter(pub): |
631 | 781 |
pub.user_class.wipe() |
632 | 782 |
user = create_superuser(pub) |
633 |
create_environment(pub) |
|
634 |
formdef = FormDef.get_by_urlname('form-title') |
|
783 |
pub.role_class.wipe() |
|
784 |
role = pub.role_class(name='test') |
|
785 |
role.store() |
|
786 | ||
787 |
FormDef.wipe() |
|
788 |
formdef = FormDef() |
|
789 |
formdef.name = 'form-title' |
|
790 |
formdef.fields = [] |
|
791 |
formdef.workflow_roles = {'_receiver': role.id} |
|
635 | 792 |
formdef.backoffice_submission_roles = user.roles |
636 | 793 |
formdef.store() |
637 | 794 | |
... | ... | |
640 | 797 |
user2 = pub.user_class(name='userB') |
641 | 798 |
user2.store() |
642 | 799 | |
643 |
for i, formdata in enumerate(formdef.data_class().select()): |
|
644 |
formdata.submission_agent_id = str(user1.id if i < 10 else user2.id) |
|
645 |
formdata.status = 'wf-new' |
|
800 |
data_class = formdef.data_class() |
|
801 |
data_class.wipe() |
|
802 | ||
803 |
for i in range(0, 2): |
|
804 |
formdata = data_class() |
|
805 |
formdata.data = {} |
|
806 |
formdata.submission_agent_id = str(user1.id if bool(i % 2) else user2.id) |
|
807 |
formdata.just_created() |
|
808 |
formdata.jump_status('new') |
|
646 | 809 |
formdata.store() |
647 | 810 | |
648 | 811 |
app = login(get_app(pub)) |
... | ... | |
659 | 822 |
resp = app.get(base_url + '&filter-submission-agent=on&filter-submission-agent-value=%s' % user1.id) |
660 | 823 |
assert resp.text.count('>userA<') > 0 |
661 | 824 |
assert resp.text.count('>userB<') == 0 |
662 |
assert resp.text.count('<tr') == 11
|
|
825 |
assert resp.text.count('<tr') == 2
|
|
663 | 826 |
assert resp.pyquery.find('input[value=userA]') # displayed in sidebar |
664 | 827 |
# check it persits on filter changes |
665 | 828 |
resp = resp.forms['listing-settings'].submit() |
666 | 829 |
assert resp.text.count('>userA<') > 0 |
667 | 830 |
assert resp.text.count('>userB<') == 0 |
668 |
assert resp.text.count('<tr') == 11
|
|
831 |
assert resp.text.count('<tr') == 2
|
|
669 | 832 | |
670 | 833 |
resp = app.get(base_url + '&filter-submission-agent=on&filter-submission-agent-value=%s' % user2.id) |
671 | 834 |
assert resp.text.count('>userA<') == 0 |
672 | 835 |
assert resp.text.count('>userB<') > 0 |
673 |
assert resp.text.count('<tr') == 42
|
|
836 |
assert resp.text.count('<tr') == 2 |
|
674 | 837 | |
675 | 838 |
resp = app.get( |
676 | 839 |
'/backoffice/management/form-title/?limit=100&filter-submission-agent=on&filter-submission-agent-value=%s' |
677 | 840 |
% user2.id |
678 | 841 |
) |
679 |
assert resp.text.count('<tr') == 42
|
|
842 |
assert resp.text.count('<tr') == 2 |
|
680 | 843 | |
681 | 844 |
# filter on uuid |
682 | 845 |
user1.name_identifiers = ['0123456789'] |
... | ... | |
697 | 860 | |
698 | 861 | |
699 | 862 |
def test_backoffice_table_varname_filter(pub): |
863 |
pub.user_class.wipe() |
|
700 | 864 |
create_superuser(pub) |
701 |
create_environment(pub) |
|
865 |
pub.role_class.wipe() |
|
866 |
role = pub.role_class(name='test') |
|
867 |
role.store() |
|
868 | ||
869 |
datasource = {'type': 'formula', 'value': repr([('A', 'aa'), ('B', 'bb'), ('C', 'cc')])} |
|
870 |
FormDef.wipe() |
|
871 |
formdef = FormDef() |
|
872 |
formdef.name = 'form-title' |
|
873 |
formdef.fields = [ |
|
874 |
fields.ItemField(id='3', label='3rd field', type='item', data_source=datasource, varname='foo'), |
|
875 |
] |
|
876 |
formdef.workflow_roles = {'_receiver': role.id} |
|
877 |
formdef.store() |
|
878 | ||
879 |
data_class = formdef.data_class() |
|
880 |
data_class.wipe() |
|
881 | ||
882 |
for i in range(0, 2): |
|
883 |
formdata = data_class() |
|
884 |
formdata.data = {} |
|
885 |
formdata.data['3'] = 'A' if bool(i % 2) else 'B' |
|
886 |
formdata.data['3_display'] = 'aa' if bool(i % 2) else 'bb' |
|
887 |
formdata.just_created() |
|
888 |
formdata.jump_status('new') |
|
889 |
formdata.store() |
|
702 | 890 | |
703 | 891 |
app = login(get_app(pub)) |
704 | 892 |
resp = app.get('/backoffice/management/form-title/?filter-foo=A') |
705 | 893 |
# check filter is applied |
706 |
assert resp.text.count('<tr') == 6
|
|
894 |
assert resp.text.count('<tr') == 2
|
|
707 | 895 |
# and kept in parameters |
708 | 896 |
assert resp.forms['listing-settings']['filter-3'].checked |
709 | 897 |
assert resp.forms['listing-settings']['filter-3-value'].value == 'A' |
710 | 898 | |
711 | 899 |
resp = resp.forms['listing-settings'].submit() |
712 |
assert resp.text.count('<tr') == 6
|
|
900 |
assert resp.text.count('<tr') == 2
|
|
713 | 901 | |
714 | 902 | |
715 |
def test_backoffice_block_field_filter(pub, local_user):
|
|
903 |
def test_backoffice_block_field_filter(pub): |
|
716 | 904 |
if not pub.is_using_postgresql(): |
717 | 905 |
pytest.skip('this requires SQL') |
718 | 906 | |
907 |
pub.user_class.wipe() |
|
719 | 908 |
create_superuser(pub) |
909 |
pub.role_class.wipe() |
|
910 |
role = pub.role_class(name='test') |
|
911 |
role.store() |
|
912 | ||
720 | 913 |
NamedDataSource.wipe() |
721 | 914 |
data_source = NamedDataSource(name='foobar') |
722 | 915 |
data_source.data_source = { |
... | ... | |
737 | 930 |
] |
738 | 931 |
block.store() |
739 | 932 | |
740 |
pub.role_class.wipe() |
|
741 |
role = pub.role_class(name='test') |
|
742 |
role.store() |
|
743 | ||
744 |
local_user.roles = [role.id] |
|
745 |
local_user.store() |
|
746 | ||
747 | 933 |
FormDef.wipe() |
748 | 934 |
formdef = FormDef() |
749 | 935 |
formdef.name = 'form-title' |
... | ... | |
751 | 937 |
formdef.fields = [ |
752 | 938 |
fields.BlockField(id='0', label='Block Data', varname='blockdata', type='block:foobar', max_items=3), |
753 | 939 |
] |
940 |
formdef.workflow_roles = {'_receiver': role.id} |
|
754 | 941 |
formdef.store() |
755 | 942 | |
756 | 943 |
data_class = formdef.data_class() |
... | ... | |
787 | 974 |
'5': 'a@localhost', |
788 | 975 |
}, |
789 | 976 |
) |
790 |
formdata.user_id = local_user.id |
|
791 | 977 |
formdata.just_created() |
792 | 978 |
formdata.jump_status('new') |
793 | 979 |
formdata.store() |
794 |
- |