From 52c55946c5a8431f538d37aeb237c8ea12fec578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20NO=C3=8BL?= Date: Sat, 21 Nov 2020 15:27:38 +0100 Subject: [PATCH] seisin: search attachments in workflow fields (#48738) --- passerelle_minint/minint_seisin/views.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/passerelle_minint/minint_seisin/views.py b/passerelle_minint/minint_seisin/views.py index 61557ca..54141d2 100644 --- a/passerelle_minint/minint_seisin/views.py +++ b/passerelle_minint/minint_seisin/views.py @@ -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