Code Duplication    Length = 78-82 lines in 2 locations

src/bika/lims/controlpanel/bika_sampletypes.py 1 location

@@ 43-124 (lines=82) @@
40
41
class SampleTypesView(BikaListingView):
42
43
    def __init__(self, context, request):
44
        super(SampleTypesView, self).__init__(context, request)
45
46
        self.catalog = SETUP_CATALOG
47
        self.contentFilter = {
48
            "portal_type": "SampleType",
49
            "sort_on": "sortable_title",
50
            "sort_order": "ascending",
51
            "path": {
52
                "query": api.get_path(self.context),
53
                "depth": 1,
54
            }
55
        }
56
57
        self.context_actions = {
58
            _("Add"): {
59
                "url": "createObject?type_name=SampleType",
60
                "permission": AddSampleType,
61
                "icon": "++resource++bika.lims.images/add.png"}
62
        }
63
64
        self.title = self.context.translate(_("Sample Types"))
65
        self.icon = "{}/{}".format(
66
            self.portal_url,
67
            "/++resource++bika.lims.images/sampletype_big.png"
68
        )
69
70
        self.description = ""
71
72
        self.show_select_row = False
73
        self.show_select_column = True
74
        self.pagesize = 25
75
76
        self.columns = collections.OrderedDict((
77
            ("Title", {
78
                "title": _("Sample Type"),
79
                "index": "sortable_title"}),
80
            ("Description", {
81
                "title": _("Description"),
82
                "index": "description",
83
                "toggle": True}),
84
            ("getHazardous", {
85
                "title": _("Hazardous"),
86
                "toggle": True}),
87
            ("getPrefix", {
88
                "title": _("Prefix"),
89
                "toggle": True}),
90
            ("getMinimumVolume", {
91
                "title": _("Minimum Volume"),
92
                "toggle": True}),
93
            ("RetentionPeriod", {
94
                "title": _("Retention Period"),
95
                "toggle": True}),
96
            ("SampleMatrix", {
97
                "title": _("SampleMatrix"),
98
                "toggle": True}),
99
            ("ContainerType", {
100
                "title": _("Default Container"),
101
                "toggle": True}),
102
            ("SamplePoints", {
103
                "title": _("Sample Points"),
104
                "toggle": True}),
105
        ))
106
107
        self.review_states = [
108
            {
109
                "id": "default",
110
                "title": _("Active"),
111
                "contentFilter": {"is_active": True},
112
                "transitions": [{"id": "deactivate"}, ],
113
                "columns": self.columns.keys(),
114
            }, {
115
                "id": "inactive",
116
                "title": _("Inactive"),
117
                "contentFilter": {'is_active': False},
118
                "transitions": [{"id": "activate"}, ],
119
                "columns": self.columns.keys(),
120
            }, {
121
                "id": "all",
122
                "title": _("All"),
123
                "contentFilter": {},
124
                "columns": self.columns.keys(),
125
            }
126
        ]
127

src/bika/lims/browser/batchfolder.py 1 location

@@ 39-116 (lines=78) @@
36
    """Listing view for Batches
37
    """
38
39
    def __init__(self, context, request):
40
        super(BatchFolderContentsView, self).__init__(context, request)
41
42
        self.catalog = BIKA_CATALOG
43
        self.contentFilter = {
44
            "portal_type": "Batch",
45
            "sort_on": "created",
46
            "sort_order": "descending",
47
            "is_active": True,
48
        }
49
50
        self.title = self.context.translate(_("Batches"))
51
        self.description = ""
52
53
        self.show_select_column = True
54
        self.form_id = "batches"
55
        self.context_actions = {}
56
        self.icon = "{}{}".format(self.portal_url, "/senaite_theme/icon/batch")
57
58
        self.columns = collections.OrderedDict((
59
            ("Title", {
60
                "title": _("Title"),
61
                "index": "title", }),
62
            ("Progress", {
63
                "title": _("Progress"),
64
                "index": "getProgress",
65
                "sortable": True,
66
                "toggle": True}),
67
            ("BatchID", {
68
                "title": _("Batch ID"),
69
                "index": "getId", }),
70
            ("Description", {
71
                "title": _("Description"),
72
                "sortable": False, }),
73
            ("BatchDate", {
74
                "title": _("Date"), }),
75
            ("Client", {
76
                "title": _("Client"),
77
                "index": "getClientTitle", }),
78
            ("ClientID", {
79
                "title": _("Client ID"),
80
                "index": "getClientID", }),
81
            ("ClientBatchID", {
82
                "title": _("Client Batch ID"),
83
                "index": "getClientBatchID", }),
84
            ("state_title", {
85
                "title": _("State"),
86
                "sortable": False, }),
87
            ("created", {
88
                "title": _("Created"),
89
                "index": "created",
90
            }),
91
        ))
92
93
        self.review_states = [
94
            {
95
                "id": "default",
96
                "contentFilter": {"review_state": "open"},
97
                "title": _("Open"),
98
                "transitions": [],
99
                "columns": self.columns.keys(),
100
            }, {
101
                "id": "closed",
102
                "contentFilter": {"review_state": "closed"},
103
                "title": _("Closed"),
104
                "transitions": [],
105
                "columns": self.columns.keys(),
106
            }, {
107
                "id": "cancelled",
108
                "title": _("Cancelled"),
109
                "transitions": [],
110
                "contentFilter": {"is_active": False},
111
                "columns": self.columns.keys(),
112
            }, {
113
                "id": "all",
114
                "title": _("All"),
115
                "transitions": [],
116
                "columns": self.columns.keys(),
117
            },
118
        ]
119