Code Duplication    Length = 73-79 lines in 4 locations

src/senaite/core/browser/controlpanel/sampletemplates/view.py 1 location

@@ 32-110 (lines=79) @@
29
from senaite.core.permissions import AddSampleTemplate
30
31
32
class SampleTemplatesView(ListingView):
33
34
    def __init__(self, context, request):
35
        super(SampleTemplatesView, self).__init__(context, request)
36
37
        self.catalog = SETUP_CATALOG
38
        self.show_select_column = True
39
40
        self.contentFilter = {
41
            "portal_type": "SampleTemplate",
42
            "sort_on": "sortable_title",
43
            "sort_order": "ascending",
44
            # restrict the search to the current folder only
45
            "path": {
46
                "query": api.get_path(context),
47
                "level": 0,
48
            }
49
        }
50
51
        self.context_actions = {
52
            _(u"listing_sampletemplates_action_add", default=u"Add"): {
53
                "url": "++add++SampleTemplate",
54
                "permission": AddSampleTemplate,
55
                "icon": "senaite_theme/icon/plus"
56
            }
57
        }
58
59
        self.title = translate(_(
60
            u"listing_sampletemplates_title",
61
            default=u"Sample Templates")
62
        )
63
        self.icon = api.get_icon("SampleTemplates", html_tag=False)
64
65
        self.columns = collections.OrderedDict((
66
            ("Title", {
67
                "title": _(
68
                    u"listing_sampletemplates_column_title",
69
                    default=u"Sample Template"
70
                ),
71
                "index": "sortable_title"}),
72
            ("Description", {
73
                "title": _(
74
                    u"listing_sampletemplates_column_description",
75
                    default=u"Description"
76
                ),
77
                "toggle": True}),
78
        ))
79
80
        self.review_states = [
81
            {
82
                "id": "default",
83
                "title": _(
84
                    u"listing_sampletemplates_state_active",
85
                    default=u"Active"
86
                ),
87
                "contentFilter": {"is_active": True},
88
                "columns": self.columns.keys(),
89
            }, {
90
                "id": "inactive",
91
                "title": _(
92
                    u"listing_sampletemplates_state_inactive",
93
                    default=u"Inactive"
94
                ),
95
                "contentFilter": {"is_active": False},
96
                "columns": self.columns.keys(),
97
            }, {
98
                "id": "all",
99
                "title": _(
100
                    u"listing_sampletemplates_state_all",
101
                    default=u"All"
102
                ),
103
                "contentFilter": {},
104
                "columns": self.columns.keys(),
105
            },
106
        ]
107
108
    def folderitem(self, obj, item, index):
109
        item["replace"]["Title"] = get_link_for(obj)
110
        return item
111

src/senaite/core/browser/controlpanel/containertypes/view.py 1 location

@@ 32-109 (lines=78) @@
29
from senaite.core.permissions import AddContainerType
30
31
32
class ContainerTypesView(ListingView):
33
34
    def __init__(self, context, request):
35
        super(ContainerTypesView, self).__init__(context, request)
36
37
        self.catalog = SETUP_CATALOG
38
        self.show_select_column = True
39
40
        self.contentFilter = {
41
            "portal_type": "ContainerType",
42
            "sort_on": "sortable_title",
43
            "sort_order": "ascending",
44
            "path": {
45
                "query": api.get_path(context),
46
                "depth": 1,
47
            }
48
        }
49
50
        self.context_actions = {
51
            _("listing_containertypes_action_add", default="Add"): {
52
                "url": "++add++ContainerType",
53
                "permission": AddContainerType,
54
                "icon": "senaite_theme/icon/plus"
55
            }
56
        }
57
58
        self.title = translate(_(
59
            "listing_containertypes_title",
60
            default="Container Types")
61
        )
62
        self.icon = api.get_icon("ContainerTypes", html_tag=False)
63
64
        self.columns = collections.OrderedDict((
65
            ("Title", {
66
                "title": _(
67
                    "listing_containertypes_column_title",
68
                    default="Title"
69
                ),
70
                "index": "sortable_title"}),
71
            ("Description", {
72
                "title": _(
73
                    "listing_containertypes_column_description",
74
                    default="Description"
75
                ),
76
                "toggle": True}),
77
        ))
78
79
        self.review_states = [
80
            {
81
                "id": "default",
82
                "title": _(
83
                    "listing_containertypes_state_active",
84
                    default="Active"
85
                ),
86
                "contentFilter": {"is_active": True},
87
                "columns": self.columns.keys(),
88
            }, {
89
                "id": "inactive",
90
                "title": _(
91
                    "listing_containertypes_state_inactive",
92
                    default="Inactive"
93
                ),
94
                "contentFilter": {"is_active": False},
95
                "columns": self.columns.keys(),
96
            }, {
97
                "id": "all",
98
                "title": _(
99
                    "listing_containertypes_state_all",
100
                    default="All"
101
                ),
102
                "contentFilter": {},
103
                "columns": self.columns.keys(),
104
            },
105
        ]
106
107
    def folderitem(self, obj, item, index):
108
        item["replace"]["Title"] = get_link_for(obj)
109
        return item
110

src/senaite/core/browser/controlpanel/samplematrices/view.py 1 location

@@ 32-105 (lines=74) @@
29
from senaite.core.permissions import AddSampleMatrix
30
31
32
class SampleMatricesView(ListingView):
33
34
    def __init__(self, context, request):
35
        super(SampleMatricesView, self).__init__(context, request)
36
37
        self.catalog = SETUP_CATALOG
38
        self.show_select_column = True
39
40
        self.contentFilter = {
41
            "portal_type": "SampleMatrix",
42
            "sort_on": "sortable_title",
43
            "sort_order": "ascending",
44
        }
45
46
        self.context_actions = {
47
            _(u"listing_samplematrices_action_add", default=u"Add"): {
48
                "url": "++add++SampleMatrix",
49
                "permission": AddSampleMatrix,
50
                "icon": "senaite_theme/icon/plus"
51
            }
52
        }
53
54
        self.title = translate(_(
55
            u"listing_samplematrices_title",
56
            default=u"Sample Matrices")
57
        )
58
        self.icon = api.get_icon("SampleMatrices", html_tag=False)
59
60
        self.columns = collections.OrderedDict((
61
            ("Title", {
62
                "title": _(
63
                    u"listing_samplematrices_column_title",
64
                    default=u"Sample Matrix"
65
                ),
66
                "index": "sortable_title"}),
67
            ("Description", {
68
                "title": _(
69
                    u"listing_samplematrices_column_description",
70
                    default=u"Description"
71
                ),
72
                "toggle": True}),
73
        ))
74
75
        self.review_states = [
76
            {
77
                "id": "default",
78
                "title": _(
79
                    u"listing_samplematrices_state_active",
80
                    default=u"Active"
81
                ),
82
                "contentFilter": {"is_active": True},
83
                "columns": self.columns.keys(),
84
            }, {
85
                "id": "inactive",
86
                "title": _(
87
                    u"listing_samplematrices_state_inactive",
88
                    default=u"Inactive"
89
                ),
90
                "contentFilter": {"is_active": False},
91
                "columns": self.columns.keys(),
92
            }, {
93
                "id": "all",
94
                "title": _(
95
                    u"listing_samplematrices_state_all",
96
                    default=u"All"
97
                ),
98
                "contentFilter": {},
99
                "columns": self.columns.keys(),
100
            },
101
        ]
102
103
    def folderitem(self, obj, item, index):
104
        item["replace"]["Title"] = get_link_for(obj)
105
        return item
106

src/senaite/core/browser/controlpanel/batchlabels/view.py 1 location

@@ 32-104 (lines=73) @@
29
from senaite.core.permissions import AddBatchLabel
30
31
32
class BatchLabelsView(ListingView):
33
34
    def __init__(self, context, request):
35
        super(BatchLabelsView, self).__init__(context, request)
36
37
        self.catalog = SETUP_CATALOG
38
39
        self.contentFilter = {
40
            "portal_type": "BatchLabel",
41
            "sort_on": "sortable_title",
42
            "sort_order": "ascending",
43
            "path": {
44
                "query": api.get_path(context),
45
                "depth": 1,
46
            }
47
        }
48
49
        self.context_actions = {
50
            _("listing_batchlabels_action_add", default="Add"): {
51
                "url": "++add++BatchLabel",
52
                "permission": AddBatchLabel,
53
                "icon": "senaite_theme/icon/plus"
54
            }
55
        }
56
57
        self.title = translate(_(
58
            "listing_batchlabels_title",
59
            default="Batch Labels")
60
        )
61
62
        self.icon = api.get_icon("BatchLabels", html_tag=False)
63
        self.description = ""
64
65
        self.columns = collections.OrderedDict((
66
            ("Title", {
67
                "title": _(
68
                    u"listing_batchlabels_column_title",
69
                    default=u"Title"
70
                ),
71
                "index": "sortable_title"}),
72
            ))
73
74
        self.review_states = [
75
            {
76
                "id": "default",
77
                "title": _(
78
                    u"listing_batchlabels_state_active",
79
                    default=u"Active"
80
                ),
81
                "contentFilter": {"is_active": True},
82
                "columns": self.columns.keys(),
83
            }, {
84
                "id": "inactive",
85
                "title": _(
86
                    u"listing_batchlabels_state_inactive",
87
                    default=u"Inactive"
88
                ),
89
                "contentFilter": {"is_active": False},
90
                "columns": self.columns.keys(),
91
            }, {
92
                "id": "all",
93
                "title": _(
94
                    u"listing_batchlabels_state_all",
95
                    default=u"All"
96
                ),
97
                "contentFilter": {},
98
                "columns": self.columns.keys(),
99
            },
100
        ]
101
102
    def folderitem(self, obj, item, index):
103
        item["replace"]["Title"] = get_link_for(obj)
104
        return item
105