Improve document not found error handling

This commit is contained in:
Lorenz Padberg 2022-08-03 11:25:19 +02:00
parent 21413b183a
commit 88a9d98c0a
1 changed files with 15 additions and 12 deletions

View File

@ -88,18 +88,21 @@ def augment_fields(raw_data):
data['value'] = augment_fields(item_data) data['value'] = augment_fields(item_data)
if _type == 'cms_document_block': if _type == 'cms_document_block':
_value = data['value'] try:
document = CustomDocument.objects.get(id=_value) _value = data['value']
value = { document = CustomDocument.objects.get(id=_value)
'value': _value, value = {
'id': document.id, 'value': _value,
'file_name': document.filename, 'id': document.id,
'file_extension': document.file_extension, 'file_name': document.filename,
'url': document.url, 'file_extension': document.file_extension,
'title': document.title, 'url': document.url,
'display_text': document.display_text 'title': document.title,
} 'display_text': document.display_text
data['value'] = value }
data['value'] = value
except CustomDocument.DoesNotExist:
logger.error('CustomDocument {} does not exist'.format(_value))
return raw_data return raw_data