Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle unicode queries in Client ReferenceWidgetVocabulary #606

Merged
merged 3 commits into from
Jan 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions bika/lims/browser/client/ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,36 @@
# Copyright 2018 by it's authors.
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.

import plone, json
import json

import plone
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace between these two imports. I suggest to remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so as well, but somehow isort is keeping always adding that blank line between those two...

from bika.lims.adapters.referencewidgetvocabulary import \
DefaultReferenceWidgetVocabulary
from bika.lims.browser import BrowserView
from Products.CMFCore.utils import getToolByName


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', [])
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)


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')
Expand Down