bika.health.ajax.bikasetup   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 14
dl 0
loc 48
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A BikaSetupAjaxHandler.getDefaultPatientPublicationSettings() 0 22 1
1
# -*- coding: utf-8 -*-
2
#
3
# This file is part of SENAITE.HEALTH.
4
#
5
# SENAITE.HEALTH is free software: you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by the Free
7
# Software Foundation, version 2.
8
#
9
# This program is distributed in the hope that it will be useful, but WITHOUT
10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12
# details.
13
#
14
# You should have received a copy of the GNU General Public License along with
15
# this program; if not, write to the Free Software Foundation, Inc., 51
16
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
#
18
# Copyright 2018-2019 by it's authors.
19
# Some rights reserved, see README and LICENSE.
20
21
from bika.health.ajax.ajaxhandler import AjaxHandler
22
23
24
class BikaSetupAjaxHandler(AjaxHandler):
25
26
    def getDefaultPatientPublicationSettings(self, params):
27
        """ Returns the settings for the publication of results to patients.
28
            The first output param is a dictionary with the following
29
            key/values:
30
            - AllowResultsDistributionToPatients: true/false
31
            - PatientPublicationPreferences: array of strings (email, etc.)
32
            - PatientPublicationAttachmentsPermitted: true/false
33
            The first output param is Null if there was an error.
34
            The second output param is an error message if there was an error
35
            invoking the method. Null if there was no error.
36
        """
37
        ALLOW = 'AllowResultsDistributionToPatients'
38
        PREF = 'PatientPublicationPreferences'
39
        ATTACH = 'PatientPublicationAttachmentsPermitted'
40
41
        bs = self.context.bika_setup
42
        sch = bs.Schema()
43
        res = {ALLOW: sch[ALLOW].get(bs),
44
                PREF: sch[PREF].get(bs),
45
                ATTACH: sch[ATTACH].get(bs)}
46
47
        return res, None
48