Passed
Push — master ( dd6af3...02661d )
by Ramon
12:19 queued 05:12
created

PrimaryAnalysisRequestViewlet.get_partitions()   A

Complexity

Conditions 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 3
nop 1
1
# -*- coding: utf-8 -*-
2
#
3
# This file is part of SENAITE.CORE.
4
#
5
# SENAITE.CORE is free software: you can redistribute it and/or modify it under
6
# the terms of the GNU General Public License as published by the Free Software
7
# 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 Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
22
from plone.app.layout.viewlets import ViewletBase
23
from bika.lims import api
24
25
26
class InvalidAnalysisRequestViewlet(ViewletBase):
27
    """ Current Analysis Request is invalid and display the link to the retest
28
    """
29
    template = ViewPageTemplateFile("templates/invalid_ar_viewlet.pt")
30
31
32
class RetestAnalysisRequestViewlet(ViewletBase):
33
    """ Current Analysis Request is a retest. Display the link to the invalid
34
    """
35
    template = ViewPageTemplateFile("templates/retest_ar_viewlet.pt")
36
37
38
class PrimaryAnalysisRequestViewlet(ViewletBase):
39
    """ Current Analysis Request is a primary. Display links to partitions
40
    """
41
    template = ViewPageTemplateFile("templates/primary_ar_viewlet.pt")
42
43
    def get_partitions(self):
44
        """Returns whether this viewlet is visible or not
45
        """
46
        # If current user is a client contact, rely on Setup's ShowPartitions
47
        if api.get_current_client():
48
            if not api.get_setup().getShowPartitions():
49
                return []
50
        return self.context.getDescendants()
51
52
53
class PartitionAnalysisRequestViewlet(ViewletBase):
54
    """ Current Analysis Request is a partition. Display the link to primary
55
    """
56
    template = ViewPageTemplateFile("templates/partition_ar_viewlet.pt")
57
58
59
class SecondaryAnalysisRequestViewlet(ViewletBase):
60
    """ Current Analysis Request is a secondary. Display the link to primary
61
    """
62
    template = ViewPageTemplateFile("templates/secondary_ar_viewlet.pt")
63
64
65
class RejectedAnalysisRequestViewlet(ViewletBase):
66
    """Current ANalysis Request was rejected. Display the reasons
67
    """
68
    template = ViewPageTemplateFile("templates/rejected_ar_viewlet.pt")
69