Total Complexity | 4 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # -*- coding: utf-8 -*- |
||
2 | # |
||
3 | # This file is part of SENAITE.CORE |
||
4 | # |
||
5 | # Copyright 2018 by it's authors. |
||
6 | # Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst. |
||
7 | |||
8 | import json |
||
9 | |||
10 | import plone |
||
11 | from Products.CMFCore.utils import getToolByName |
||
12 | from bika.lims.browser import BrowserView |
||
13 | |||
14 | |||
15 | class ajaxGetMethodCalculation(BrowserView): |
||
16 | """ Returns the calculation assigned to the defined method. |
||
17 | uid: unique identifier of the method |
||
18 | """ |
||
19 | def __call__(self): |
||
20 | plone.protect.CheckAuthenticator(self.request) |
||
21 | calcdict = {} |
||
22 | uc = getToolByName(self, 'uid_catalog') |
||
23 | method = uc(UID=self.request.get("uid", '0')) |
||
24 | if method and len(method) == 1: |
||
25 | calc = method[0].getObject().getCalculation() |
||
26 | if calc: |
||
27 | calcdict = {'uid': calc.UID(), |
||
28 | 'title': calc.Title()} |
||
29 | return json.dumps(calcdict) |
||
30 |