Passed
Push — master ( ef1ceb...20aa4c )
by Jordi
06:12
created

bika.lims.browser.analysisrequest.tables   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 92
Duplicated Lines 63.04 %

Importance

Changes 0
Metric Value
wmc 3
eloc 53
dl 58
loc 92
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A QCAnalysesTable.__init__() 0 8 1
A FieldAnalysesTable.__init__() 25 25 1
A LabAnalysesTable.__init__() 25 25 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
from bika.lims import api
9
from bika.lims import bikaMessageFactory as _
10
from bika.lims.browser.analyses.qc import QCAnalysesView
11
from bika.lims.browser.analyses.view import AnalysesView
12
13
14 View Code Duplication
class LabAnalysesTable(AnalysesView):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
15
    """Lab Analyses Listing Table for ARs
16
    """
17
18
    def __init__(self, context, request):
19
        super(LabAnalysesTable, self).__init__(context, request)
20
21
        self.contentFilter.update({
22
            "getPointOfCapture": "lab",
23
            "getRequestUID": api.get_uid(context)
24
        })
25
26
        self.form_id = "lab_analyses"
27
        self.allow_edit = True
28
        self.show_workflow_action_buttons = True
29
        self.show_select_column = True
30
        self.show_search = False
31
32
        self.review_states = [
33
            {
34
                "id": "default",
35
                "title": _("All"),
36
                "contentFilter": {},
37
                "transitions": [
38
                    {"id": "submit"},
39
                    {"id": "retract"},
40
                    {"id": "verify"},
41
                ],
42
                "columns": self.columns.keys()
43
             },
44
        ]
45
46
47 View Code Duplication
class FieldAnalysesTable(AnalysesView):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
48
    """Field Analyses Listing Table for ARs
49
    """
50
51
    def __init__(self, context, request):
52
        super(FieldAnalysesTable, self).__init__(context, request)
53
54
        self.contentFilter.update({
55
            "getPointOfCapture": "field",
56
            "getRequestUID": api.get_uid(context)
57
        })
58
59
        self.form_id = "field_analyses"
60
        self.allow_edit = True
61
        self.show_workflow_action_buttons = True
62
        self.show_select_column = True
63
        self.show_search = False
64
65
        self.review_states = [
66
            {
67
                "id": "default",
68
                "title": _("All"),
69
                "contentFilter": {},
70
                "transitions": [
71
                    {"id": "submit"},
72
                    {"id": "retract"},
73
                    {"id": "verify"},
74
                ],
75
                "columns": self.columns.keys()
76
             },
77
        ]
78
79
80
class QCAnalysesTable(QCAnalysesView):
81
    """QC Analyses Listing Table for ARs
82
    """
83
84
    def __init__(self, context, request):
85
        super(QCAnalysesTable, self).__init__(context, request)
86
87
        self.form_id = "qc_analyses"
88
        self.allow_edit = False
89
        self.show_select_column = False
90
        self.show_workflow_action_buttons = False
91
        self.show_search = False
92