backoffice: show some fields in additional options if empty only (#58752)
gitea-wip/wcs/pipeline/head Build started... Details

This commit is contained in:
Lauréline Guérin 2021-12-09 12:04:42 +01:00
parent 1008eb5099
commit ba54e9fe1d
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 26 additions and 4 deletions

View File

@ -447,7 +447,7 @@ def test_data_sources_edit(pub):
create_superuser(pub)
NamedDataSource.wipe()
data_source = NamedDataSource(name='foobar')
data_source.data_source = {'type': 'formula', 'value': '[]'}
data_source.data_source = {'type': 'json', 'value': 'http://some.url'}
data_source.store()
FormDef.wipe()
@ -463,6 +463,28 @@ def test_data_sources_edit(pub):
assert NamedDataSource.get(1).description == 'data source description'
resp = app.get('/backoffice/settings/data-sources/1/edit')
assert '<legend>Additional options</legend>' in resp.text
assert '>Data Attribute</label>' in resp.text
assert '>Id Attribute</label>' in resp.text
assert '>Text Attribute</label>' in resp.text
assert resp.text.index('<legend>Additional options</legend>') < resp.text.index('>Data Attribute</label>')
assert resp.text.index('>Data Attribute</label>') < resp.text.index('>Id Attribute</label>')
assert resp.text.index('>Id Attribute</label>') < resp.text.index('>Text Attribute</label>')
data_source.data_attribute = 'data'
data_source.id_attribute = 'id'
data_source.text_attribute = 'text'
data_source.store()
resp = app.get('/backoffice/settings/data-sources/1/edit')
assert '<legend>Additional options</legend>' in resp.text
assert '>Data Attribute</label>' in resp.text
assert '>Id Attribute</label>' in resp.text
assert '>Text Attribute</label>' in resp.text
assert resp.text.index('>Data Attribute</label>') < resp.text.index('>Id Attribute</label>')
assert resp.text.index('>Id Attribute</label>') < resp.text.index('>Text Attribute</label>')
assert resp.text.index('>Text Attribute</label>') < resp.text.index('<legend>Additional options</legend>')
def test_data_sources_edit_duplicate_name(pub):
create_superuser(pub)

View File

@ -186,7 +186,7 @@ class NamedDataSourceUI:
'Possibility to chain attributes with a dot separator (example: data.results)'
),
required=False,
advanced=True,
advanced=not (self.datasource.data_attribute),
attrs={
'data-dynamic-display-child-of': 'data_source$type',
'data-dynamic-display-value': 'json',
@ -199,7 +199,7 @@ class NamedDataSourceUI:
title=_('Id Attribute'),
hint=_('Name of the attribute containing the identifier of an entry (default: id)'),
required=False,
advanced=True,
advanced=not (self.datasource.id_attribute),
attrs={
'data-dynamic-display-child-of': 'data_source$type',
'data-dynamic-display-value': 'json',
@ -212,7 +212,7 @@ class NamedDataSourceUI:
title=_('Text Attribute'),
hint=_('Name of the attribute containing the label of an entry (default: text)'),
required=False,
advanced=True,
advanced=not (self.datasource.text_attribute),
attrs={
'data-dynamic-display-child-of': 'data_source$type',
'data-dynamic-display-value': 'json',