maarch: use compat.json_loads (#43464)

This commit is contained in:
Thomas NOËL 2020-05-29 17:50:13 +02:00
parent 8b554936e8
commit e3d265eb14
1 changed files with 7 additions and 6 deletions

View File

@ -115,7 +115,7 @@ class ResourceView(DetailView):
# get translations
translations_txt = extras.get('translations')
if translations_txt:
self.translations = json.loads(translations_txt)
self.translations = json_loads(translations_txt)
# logger.debug('Translation JSON: %r', translations)
document = u'<html>'
@ -382,7 +382,7 @@ class AttachmentView(DetailView):
@utils.protected_api('can_access')
def post(self, request, *args, **kwargs):
client = self.get_client()
formdata = json.loads(request.body)
formdata = json_loads(request.body)
extras = formdata.get('extra', {})
debug = 'debug' in request.GET
@ -435,6 +435,7 @@ class AttachmentView(DetailView):
# parameter. Get value from formdata or workflow options.
maarch_id = extras.get('maarch_id')
notification_email = extras.get('notification_email') if maarch_id else None
notification_model = extras.get('notification_model') if maarch_id else None
if debug:
debug_output['maarch_id'] = maarch_id
@ -454,11 +455,12 @@ class AttachmentView(DetailView):
countAttachment += 1
if maarch_id:
email_to = notification_email if notification_email and countAttachment == nbAttachments else ''
modele_ae = notification_model if notification_model and countAttachment == nbAttachments else ''
logger.debug('storeAdditionalAttachmentResource: INES maarch_id: %r', maarch_id)
client.service.storeAdditionalAttachmentResource(
maarch_id,
resId, collId, attachment['content'],
attachment['fileFormat'], attachment['filename'], email_to)
attachment['fileFormat'], attachment['filename'], email_to, modele_ae)
else:
results = client.service.storeAttachmentResource(
resId, collId, attachment['content'],
@ -481,7 +483,7 @@ class DebugView(DetailView):
@utils.protected_api('can_access')
def post(self, request, *args, **kwargs):
client = self.get_client()
formdata = json.loads(request.body)
formdata = json_loads(request.body)
extras = formdata.get('extra', {})
logger.debug('formdata %r: ', formdata)
debug = False # 'debug' in request.GET
@ -511,8 +513,7 @@ class DebugView(DetailView):
translations_txt = extras.get('translations')
if translations_txt:
# config = json.loads(open('config/defaults.json').read())
self.translations = json.loads(translations_txt)
self.translations = json_loads(translations_txt)
logger.debug('Translation JSON: %r', self.translations)
else:
logger.debug('AUCUNE Translation JSON: %r', self.translations)