backoffice: fix listing export of channel and anonymised columns (#12848)
This commit is contained in:
parent
ced4feb552
commit
6947f4b871
|
@ -491,6 +491,47 @@ def test_backoffice_csv(pub):
|
|||
resp_csv = resp.click('Export as CSV File')
|
||||
assert 'Time' not in resp_csv.body.splitlines()[0]
|
||||
|
||||
def test_backoffice_csv_export_channel(pub):
|
||||
if not pub.site_options.has_section('variables'):
|
||||
pub.site_options.add_section('variables')
|
||||
pub.site_options.set('variables', 'welco_url', 'xxx')
|
||||
fd = open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w')
|
||||
pub.site_options.write(fd)
|
||||
fd.close()
|
||||
|
||||
create_superuser(pub)
|
||||
create_environment(pub)
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/management/form-title/')
|
||||
resp_csv = resp.click('Export as CSV File')
|
||||
assert 'Channel' not in resp_csv.body.splitlines()[0]
|
||||
|
||||
# add submission channel column
|
||||
resp.form['submission_channel'].checked = True
|
||||
resp = resp.forms[0].submit()
|
||||
resp_csv = resp.click('Export as CSV File')
|
||||
assert resp_csv.body.splitlines()[0].split(',')[1] == 'Channel'
|
||||
assert resp_csv.body.splitlines()[1].split(',')[1] == 'Web'
|
||||
|
||||
def test_backoffice_csv_export_anonymised(pub):
|
||||
fd = open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w')
|
||||
pub.site_options.write(fd)
|
||||
fd.close()
|
||||
|
||||
create_superuser(pub)
|
||||
create_environment(pub)
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/management/form-title/')
|
||||
resp_csv = resp.click('Export as CSV File')
|
||||
assert resp_csv.body.splitlines()[0].split(',')[-1] != 'Anonymised'
|
||||
|
||||
# add anonymised column
|
||||
resp.form['anonymised'].checked = True
|
||||
resp = resp.forms[0].submit()
|
||||
resp_csv = resp.click('Export as CSV File')
|
||||
assert resp_csv.body.splitlines()[0].split(',')[-1] == 'Anonymised'
|
||||
assert resp_csv.body.splitlines()[1].split(',')[-1] == 'No'
|
||||
|
||||
def test_backoffice_ods(pub):
|
||||
create_superuser(pub)
|
||||
create_environment(pub)
|
||||
|
|
|
@ -1213,6 +1213,10 @@ class FormPage(Directory):
|
|||
element = '-'
|
||||
elif field.type == 'status':
|
||||
element = data.get_status_label()
|
||||
elif field.type == 'submission_channel':
|
||||
element = data.get_submission_channel_label()
|
||||
elif field.type == 'anonymised':
|
||||
element = _('Yes') if data.anonymised else _('No')
|
||||
else:
|
||||
element = data.data.get(field.id, '') or ''
|
||||
if field.store_display_value:
|
||||
|
|
Loading…
Reference in New Issue