From f9e6769b9acfcd9d5521ac6ea12a9c5c8ce0f7c6 Mon Sep 17 00:00:00 2001 From: Ramon Bartl Date: Thu, 25 Jan 2018 14:20:52 +0100 Subject: [PATCH 1/3] PEP8 and docstrings only --- bika/lims/browser/client/ajax.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bika/lims/browser/client/ajax.py b/bika/lims/browser/client/ajax.py index 75c5d90120..41b4b5d161 100644 --- a/bika/lims/browser/client/ajax.py +++ b/bika/lims/browser/client/ajax.py @@ -5,8 +5,9 @@ # Copyright 2018 by it's authors. # Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst. -import plone, json +import json +import plone from bika.lims.adapters.referencewidgetvocabulary import \ DefaultReferenceWidgetVocabulary from bika.lims.browser import BrowserView @@ -14,6 +15,9 @@ class ReferenceWidgetVocabulary(DefaultReferenceWidgetVocabulary): + """Implements IReferenceWidgetVocabulary for Clients + """ + def __call__(self): base_query = json.loads(self.request['base_query']) portal_type = base_query.get('portal_type', []) @@ -24,6 +28,9 @@ def __call__(self): class ajaxGetClientInfo(BrowserView): + """Public exposed getClientInfo to be used by the JSON API + """ + def __call__(self): plone.protect.CheckAuthenticator(self.request) wf = getToolByName(self.context, 'portal_workflow') From ee53ed3f1a5ee7ffef902919ddb64fe861502040 Mon Sep 17 00:00:00 2001 From: Ramon Bartl Date: Thu, 25 Jan 2018 14:39:14 +0100 Subject: [PATCH 2/3] Handle unicode queries for client queries --- bika/lims/browser/client/ajax.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bika/lims/browser/client/ajax.py b/bika/lims/browser/client/ajax.py index 41b4b5d161..d1466e955a 100644 --- a/bika/lims/browser/client/ajax.py +++ b/bika/lims/browser/client/ajax.py @@ -23,7 +23,11 @@ def __call__(self): portal_type = base_query.get('portal_type', []) if 'Contact' in portal_type: base_query['getParentUID'] = [self.context.UID(), ] - self.request['base_query'] = json.dumps(base_query) + # If ensure_ascii is false, a result may be a unicode instance. This + # usually happens if the input contains unicode strings or the encoding + # parameter is used. + # see: https://github.com/senaite/senaite.core/issues/605 + self.request['base_query'] = json.dumps(base_query, ensure_ascii=False) return DefaultReferenceWidgetVocabulary.__call__(self) From 829f2befc68d4cebbc4d93130cf15c7f51cee374 Mon Sep 17 00:00:00 2001 From: Ramon Bartl Date: Thu, 25 Jan 2018 14:43:05 +0100 Subject: [PATCH 3/3] Changelog updated --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index 326b3a7384..8be14b812f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -19,6 +19,7 @@ Changelog **Fixed** +- #606 Handle unicode queries in Client ReferenceWidgetVocabulary - #603 Out of range Icons are not displayed through all Analysis states - #598 BadRequest error when changing Calculation on Analysis Service - #593 Fixed Price/Spec/Interim not set in AR Manage Analyses