seisin: search attachments in workflow fields (#48738)
This commit is contained in:
parent
6578b23176
commit
52c55946c5
|
@ -66,20 +66,28 @@ class ResourceView(DetailView):
|
|||
formdata = json_loads(request.body)
|
||||
fields = formdata.get('fields', {})
|
||||
extras = formdata.get('extra', {})
|
||||
workflow_fields = formdata.get('workflow', {}).get('fields', {})
|
||||
|
||||
debug = 'debug' in request.GET
|
||||
if debug:
|
||||
debug_output = {}
|
||||
|
||||
# attachment: only one (the first)
|
||||
# attachment: only one allowed. Search first in workflow_fields, then in fields
|
||||
attachmentData = client.factory.create('arrayOfAttachmentContent')
|
||||
attachmentData.source = '?'
|
||||
for name, value in fields.items():
|
||||
for name, value in workflow_fields.items():
|
||||
if isinstance(value, dict) and value.get('filename') and value.get('content'):
|
||||
attachmentData.fileName = '"%s"' % value['filename']
|
||||
attachmentData.attachmentType = value.get('content_type')
|
||||
attachmentData.source = value['content']
|
||||
break
|
||||
else:
|
||||
for name, value in fields.items():
|
||||
if isinstance(value, dict) and value.get('filename') and value.get('content'):
|
||||
attachmentData.fileName = '"%s"' % value['filename']
|
||||
attachmentData.attachmentType = value.get('content_type')
|
||||
attachmentData.source = value['content']
|
||||
break
|
||||
|
||||
if debug:
|
||||
debug_output['attachmentData'] = '%r' % attachmentData
|
||||
|
|
Loading…
Reference in New Issue