0001-backoffice-show-some-fields-in-additional-options-if.patch
tests/admin_pages/test_datasource.py | ||
---|---|---|
447 | 447 |
create_superuser(pub) |
448 | 448 |
NamedDataSource.wipe() |
449 | 449 |
data_source = NamedDataSource(name='foobar') |
450 |
data_source.data_source = {'type': 'formula', 'value': '[]'}
|
|
450 |
data_source.data_source = {'type': 'json', 'value': 'http://some.url'}
|
|
451 | 451 |
data_source.store() |
452 | 452 | |
453 | 453 |
FormDef.wipe() |
... | ... | |
463 | 463 | |
464 | 464 |
assert NamedDataSource.get(1).description == 'data source description' |
465 | 465 | |
466 |
resp = app.get('/backoffice/settings/data-sources/1/edit') |
|
467 |
assert '<legend>Additional options</legend>' in resp.text |
|
468 |
assert '>Data Attribute</label>' in resp.text |
|
469 |
assert '>Id Attribute</label>' in resp.text |
|
470 |
assert '>Text Attribute</label>' in resp.text |
|
471 |
assert resp.text.index('<legend>Additional options</legend>') < resp.text.index('>Data Attribute</label>') |
|
472 |
assert resp.text.index('>Data Attribute</label>') < resp.text.index('>Id Attribute</label>') |
|
473 |
assert resp.text.index('>Id Attribute</label>') < resp.text.index('>Text Attribute</label>') |
|
474 | ||
475 |
data_source.data_attribute = 'data' |
|
476 |
data_source.id_attribute = 'id' |
|
477 |
data_source.text_attribute = 'text' |
|
478 |
data_source.store() |
|
479 |
resp = app.get('/backoffice/settings/data-sources/1/edit') |
|
480 |
assert '<legend>Additional options</legend>' in resp.text |
|
481 |
assert '>Data Attribute</label>' in resp.text |
|
482 |
assert '>Id Attribute</label>' in resp.text |
|
483 |
assert '>Text Attribute</label>' in resp.text |
|
484 |
assert resp.text.index('>Data Attribute</label>') < resp.text.index('>Id Attribute</label>') |
|
485 |
assert resp.text.index('>Id Attribute</label>') < resp.text.index('>Text Attribute</label>') |
|
486 |
assert resp.text.index('>Text Attribute</label>') < resp.text.index('<legend>Additional options</legend>') |
|
487 | ||
466 | 488 | |
467 | 489 |
def test_data_sources_edit_duplicate_name(pub): |
468 | 490 |
create_superuser(pub) |
wcs/admin/data_sources.py | ||
---|---|---|
186 | 186 |
'Possibility to chain attributes with a dot separator (example: data.results)' |
187 | 187 |
), |
188 | 188 |
required=False, |
189 |
advanced=True,
|
|
189 |
advanced=not (self.datasource.data_attribute),
|
|
190 | 190 |
attrs={ |
191 | 191 |
'data-dynamic-display-child-of': 'data_source$type', |
192 | 192 |
'data-dynamic-display-value': 'json', |
... | ... | |
199 | 199 |
title=_('Id Attribute'), |
200 | 200 |
hint=_('Name of the attribute containing the identifier of an entry (default: id)'), |
201 | 201 |
required=False, |
202 |
advanced=True,
|
|
202 |
advanced=not (self.datasource.id_attribute),
|
|
203 | 203 |
attrs={ |
204 | 204 |
'data-dynamic-display-child-of': 'data_source$type', |
205 | 205 |
'data-dynamic-display-value': 'json', |
... | ... | |
212 | 212 |
title=_('Text Attribute'), |
213 | 213 |
hint=_('Name of the attribute containing the label of an entry (default: text)'), |
214 | 214 |
required=False, |
215 |
advanced=True,
|
|
215 |
advanced=not (self.datasource.text_attribute),
|
|
216 | 216 |
attrs={ |
217 | 217 |
'data-dynamic-display-child-of': 'data_source$type', |
218 | 218 |
'data-dynamic-display-value': 'json', |
219 |
- |