bika.health.browser.patient.batches   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 24
dl 0
loc 54
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A PatientBatchListingViewAdapter.before_render() 0 24 3
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.browser.batchfolder import BatchListingViewAdapter
22
from bika.health.interfaces import IPatient
23
from bika.lims import api
24
from bika.lims import bikaMessageFactory as _
25
from bika.lims.permissions import AddBatch
26
27
28
class PatientBatchListingViewAdapter(BatchListingViewAdapter):
29
30
    def before_render(self):
31
        """Called before the listing renders
32
        """
33
        super(PatientBatchListingViewAdapter, self).before_render()
34
35
        # Hide patient columns
36
        self.listing.columns['getPatientID']['toggle'] = False
37
        self.listing.columns['getClientPatientID']['toggle'] = False
38
        self.listing.columns['Patient']['toggle'] = False
39
40
        # Filter by patient
41
        query = dict(getPatientUID=api.get_uid(self.context))
42
        self.listing.contentFilter.update(query)
43
        for rv in self.listing.review_states:
44
            if "contentFilter" not in rv:
45
                rv["contentFilter"] = {}
46
            rv["contentFilter"].update(query)
47
48
        url = api.get_url(self.context)
49
        self.listing.context_actions = {
50
            _("Add"): {
51
                "url": "{}/createObject?type_name=Batch".format(url),
52
                "permission": AddBatch,
53
                "icon": "++resource++bika.lims.images/add.png"
54
            }
55
        }
56