data_sources: return an empty list for an unknown carddef (#42960)
This commit is contained in:
parent
5f8c3e5685
commit
2f6e7a3597
|
@ -5848,6 +5848,17 @@ def test_studio_card_item_link(pub, studio):
|
|||
resp = resp.click('card plop')
|
||||
assert '<div class="value">plop</div>' in resp
|
||||
|
||||
# link to a unknown carddef
|
||||
carddef2.fields = [
|
||||
fields.ItemField(id='1', label='Test', type='item',
|
||||
data_source={'type': 'carddef:unknown', 'value': ''}),
|
||||
]
|
||||
carddef2.store()
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/data/')
|
||||
resp = resp.click('bar')
|
||||
resp = resp.click('Add') # no error
|
||||
|
||||
# look without access rights
|
||||
carddef.backoffice_submission_roles = None
|
||||
carddef.workflow_roles = {'_editor': None}
|
||||
|
|
|
@ -149,7 +149,10 @@ def get_structured_items(data_source, mode=None):
|
|||
if data_source.get('type') and data_source.get('type').startswith('carddef:'):
|
||||
# cards
|
||||
from wcs.carddef import CardDef
|
||||
carddef = CardDef.get_by_urlname(data_source['type'][8:])
|
||||
try:
|
||||
carddef = CardDef.get_by_urlname(data_source['type'][8:])
|
||||
except KeyError:
|
||||
return []
|
||||
items = [x.get_data_source_structured_item()
|
||||
for x in carddef.data_class().select()
|
||||
if not x.is_draft()]
|
||||
|
|
Loading…
Reference in New Issue