[TELE-695] use json_loads from Passerelle

This commit is contained in:
Daniel Muyshond 2020-10-16 10:16:56 +02:00
parent 202529b604
commit 5c0b6e2686
3 changed files with 16 additions and 8 deletions

View File

@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.1.2] - 16/10/2020
### Changed
- Use json_loads from Passerelle instead of json.loads()
to prevent strings type errors.
As it has be done by F.Péters on this repo:
(https://git.entrouvert.org/passerelle-imio-tax-compute.git/commit/?id=e44768d33645297c77b4005bef0d1aa029c1de56)
(dmuyshond)
## [0.1.1] - 18/05/2020
### Changed
- Python 3 compatibility
- Python 3 compatibility

View File

@ -24,7 +24,6 @@
# Decorateurs des endpoints:
# serializer_type='json-api' : Permet de serializer la reponse directement dans un data + format automatique pour un raise exception.
import base64
import json
import magic
import suds
@ -37,6 +36,7 @@ from django.utils.translation import ugettext_lazy as _
from django.http import HttpResponse, Http404
from passerelle.base.models import BaseResource
from passerelle.compat import json_loads
from passerelle.utils.api import endpoint
from passerelle.utils.jsonresponse import APIError
from .soap import get_client as soap_get_client
@ -112,7 +112,7 @@ class IImioIaDelib(BaseResource):
def getItemInfos(self, request, *args, **kwargs):
id_delib_extraInfos = {}
if request.body:
load = json.loads(request.body)
load = json_loads(request.body)
ws_params = load['extra']
uid = ws_params['uid']
showExtraInfos = ws_params['showExtraInfos'] or "1"
@ -121,7 +121,7 @@ class IImioIaDelib(BaseResource):
else:
get = request.GET
uid = "uid" in get and get["uid"]
showExtraInfos = "showExtraInfos" in get and get["showExtraInfos"] or "1"
showExtraInfos = "showExtraInfos" in get and get["showExtraInfos"] or "1"
showAnnexes = "showAnnexes" in get and get["showAnnexes"] or "0"
showTemplates = "showTemplates" in get and get["showTemplates"] or "0"
client = get_client(self)
@ -138,7 +138,7 @@ class IImioIaDelib(BaseResource):
ia_delib_infos.update(ia_delib_extraInfos)
return ia_delib_infos
@endpoint(serializer_type='json-api', perm='can_access', methods=['post'])
def createItem_OLD(self, request, meetingConfigId, proposingGroupId, title, description,decision):
creationData ={'title':title,
@ -149,13 +149,13 @@ class IImioIaDelib(BaseResource):
return dict(client.service.createItem(meetingConfigId,
proposingGroupId,
creationData))
@endpoint(serializer_type='json-api', perm='can_access', methods=['post'])
def createItem(self, request, *args, **kwargs):
data = dict([(x, request.GET[x]) for x in request.GET.keys()])
extraAttrs = {}
if request.body:
load = json.loads(request.body)
load = json_loads(request.body)
# get fields from form.
data.update(load.get("fields"))
ws_params = load['extra']

View File

@ -1 +1 @@
0.1.1
0.1.2