278 |
278 |
assert ids == list(reversed(formdata_ids))
|
279 |
279 |
|
280 |
280 |
|
|
281 |
def test_backoffice_item_columns_order(pub):
|
|
282 |
pub.user_class.wipe()
|
|
283 |
create_superuser(pub)
|
|
284 |
pub.role_class.wipe()
|
|
285 |
role = pub.role_class(name='test')
|
|
286 |
role.store()
|
|
287 |
|
|
288 |
CardDef.wipe()
|
|
289 |
carddef = CardDef()
|
|
290 |
carddef.name = 'foo'
|
|
291 |
carddef.fields = [
|
|
292 |
fields.StringField(id='1', label='First Name', type='string', varname='first_name'),
|
|
293 |
fields.StringField(id='2', label='Last Name', type='string', varname='last_name'),
|
|
294 |
]
|
|
295 |
carddef.digest_templates = {'default': '{{ form_var_first_name }} {{ form_var_last_name }}'}
|
|
296 |
carddef.store()
|
|
297 |
carddef.data_class().wipe()
|
|
298 |
card = carddef.data_class()()
|
|
299 |
card.data = {
|
|
300 |
'1': 'Foo',
|
|
301 |
'2': 'Bar',
|
|
302 |
}
|
|
303 |
card.store()
|
|
304 |
card2 = carddef.data_class()()
|
|
305 |
card2.data = {
|
|
306 |
'1': 'Bar2',
|
|
307 |
'2': 'Foo2',
|
|
308 |
}
|
|
309 |
card2.store()
|
|
310 |
|
|
311 |
FormDef.wipe()
|
|
312 |
formdef = FormDef()
|
|
313 |
formdef.name = 'form-title'
|
|
314 |
formdef.fields = [
|
|
315 |
fields.ItemField(
|
|
316 |
id='456', label='card field', type='item', data_source={'type': 'carddef:foo'}, varname='item'
|
|
317 |
),
|
|
318 |
]
|
|
319 |
formdef.workflow_roles = {'_receiver': role.id}
|
|
320 |
formdef.store()
|
|
321 |
|
|
322 |
data_class = formdef.data_class()
|
|
323 |
data_class.wipe()
|
|
324 |
|
|
325 |
formdata1 = data_class()
|
|
326 |
formdata1.data = {'456': str(card.id), '456_display': card.default_digest}
|
|
327 |
formdata1.just_created()
|
|
328 |
formdata1.jump_status('new')
|
|
329 |
formdata1.store()
|
|
330 |
|
|
331 |
formdata2 = data_class()
|
|
332 |
formdata2.data = {'456': str(card2.id), '456_display': card2.default_digest}
|
|
333 |
formdata2.just_created()
|
|
334 |
formdata2.jump_status('new')
|
|
335 |
formdata2.store()
|
|
336 |
|
|
337 |
formdata3 = data_class()
|
|
338 |
formdata3.data = {}
|
|
339 |
formdata3.just_created()
|
|
340 |
formdata3.jump_status('new')
|
|
341 |
formdata3.store()
|
|
342 |
|
|
343 |
app = login(get_app(pub))
|
|
344 |
resp = app.get('/backoffice/management/form-title/?order_by=f456')
|
|
345 |
ids = [int(x.strip('/')) for x in re.findall(r'data-link="(.*?)"', resp.text)]
|
|
346 |
assert ids == [formdata2.id, formdata1.id, formdata3.id]
|
|
347 |
|
|
348 |
resp = app.get('/backoffice/management/form-title/?order_by=-f456')
|
|
349 |
ids = [int(x.strip('/')) for x in re.findall(r'data-link="(.*?)"', resp.text)]
|
|
350 |
assert ids == [formdata3.id, formdata1.id, formdata2.id]
|
|
351 |
|
|
352 |
resp = app.get('/backoffice/management/form-title/?order_by=item')
|
|
353 |
ids = [int(x.strip('/')) for x in re.findall(r'data-link="(.*?)"', resp.text)]
|
|
354 |
assert ids == [formdata2.id, formdata1.id, formdata3.id]
|
|
355 |
|
|
356 |
resp = app.get('/backoffice/management/form-title/?order_by=-item')
|
|
357 |
ids = [int(x.strip('/')) for x in re.findall(r'data-link="(.*?)"', resp.text)]
|
|
358 |
assert ids == [formdata3.id, formdata1.id, formdata2.id]
|
|
359 |
|
|
360 |
|
281 |
361 |
def test_backoffice_block_columns_order(pub):
|
282 |
362 |
pub.user_class.wipe()
|
283 |
363 |
create_superuser(pub)
|
... | ... | |
367 |
447 |
formdata3.jump_status('new')
|
368 |
448 |
formdata3.store()
|
369 |
449 |
|
370 |
|
# XXX ordering is done on card id, to be fixed with #60742
|
371 |
450 |
app = login(get_app(pub))
|
372 |
451 |
resp = app.get('/backoffice/management/form-title/?order_by=f8-456')
|
373 |
452 |
ids = [int(x.strip('/')) for x in re.findall(r'data-link="(.*?)"', resp.text)]
|
374 |
|
assert ids == [formdata1.id, formdata2.id, formdata3.id]
|
|
453 |
assert ids == [formdata2.id, formdata1.id, formdata3.id]
|
375 |
454 |
|
376 |
455 |
resp = app.get('/backoffice/management/form-title/?order_by=-f8-456')
|
377 |
456 |
ids = [int(x.strip('/')) for x in re.findall(r'data-link="(.*?)"', resp.text)]
|
378 |
|
assert ids == [formdata3.id, formdata2.id, formdata1.id]
|
|
457 |
assert ids == [formdata3.id, formdata1.id, formdata2.id]
|
379 |
458 |
|
380 |
459 |
resp = app.get('/backoffice/management/form-title/?order_by=data_item')
|
381 |
460 |
ids = [int(x.strip('/')) for x in re.findall(r'data-link="(.*?)"', resp.text)]
|
382 |
|
assert ids == [formdata1.id, formdata2.id, formdata3.id]
|
|
461 |
assert ids == [formdata2.id, formdata1.id, formdata3.id]
|
383 |
462 |
|
384 |
463 |
resp = app.get('/backoffice/management/form-title/?order_by=-data_item')
|
385 |
464 |
ids = [int(x.strip('/')) for x in re.findall(r'data-link="(.*?)"', resp.text)]
|
386 |
|
assert ids == [formdata3.id, formdata2.id, formdata1.id]
|
|
465 |
assert ids == [formdata3.id, formdata1.id, formdata2.id]
|