Code Duplication    Length = 67-69 lines in 3 locations

bika/lims/controlpanel/bika_departments.py 1 location

@@ 33-101 (lines=69) @@
30
class DepartmentsView(BikaListingView):
31
    implements(IFolderContentsView, IViewView)
32
33
    def __init__(self, context, request):
34
        super(DepartmentsView, self).__init__(context, request)
35
36
        self.catalog = "bika_setup_catalog"
37
38
        self.contentFilter = {
39
            "portal_type": "Department",
40
            "sort_order": "ascending",
41
            "sort_on": "sortable_title"
42
        }
43
44
        self.context_actions = {
45
            _("Add"): {
46
                "url": "createObject?type_name=Department",
47
                "permission": "Add portal content",
48
                "icon": "++resource++bika.lims.images/add.png"}
49
        }
50
51
        self.title = self.context.translate(_("Lab Departments"))
52
        self.icon = "{}/{}".format(
53
            self.portal_url,
54
            "/++resource++bika.lims.images/department_big.png"
55
        )
56
57
        self.show_sort_column = False
58
        self.show_select_row = False
59
        self.show_select_column = True
60
        self.pagesize = 25
61
62
        self.columns = collections.OrderedDict((
63
            ("Title", {
64
                "title": _("Department"),
65
                "index": "sortable_title"}),
66
            ("Description", {
67
                "title": _("Description"),
68
                "index": "Description",
69
                "toggle": True}),
70
            ("Manager", {
71
                "title": _("Manager"),
72
                "index": "getManagerName",
73
                "toggle": True}),
74
            ("ManagerPhone", {
75
                "title": _("Manager Phone"),
76
                "index": "getManagerPhone",
77
                "toggle": True}),
78
            ("ManagerEmail", {
79
                "title": _("Manager Email"),
80
                "index": "getManagerEmail",
81
                "toggle": True}),
82
        ))
83
84
        self.review_states = [
85
            {
86
                "id": "default",
87
                "title": _("Active"),
88
                "contentFilter": {"inactive_state": "active"},
89
                "transitions": [{"id": "deactivate"}, ],
90
                "columns": self.columns.keys(),
91
            }, {
92
                "id": "inactive",
93
                "title": _("Dormant"),
94
                "contentFilter": {"inactive_state": "inactive"},
95
                "transitions": [{"id": "activate"}, ],
96
                "columns": self.columns.keys(),
97
            }, {
98
                "id": "all",
99
                "title": _("All"),
100
                "contentFilter": {},
101
                "columns": self.columns.keys(),
102
            },
103
        ]
104

bika/lims/controlpanel/bika_labcontacts.py 1 location

@@ 31-98 (lines=68) @@
28
class LabContactsView(BikaListingView):
29
    implements(IFolderContentsView, IViewView)
30
31
    def __init__(self, context, request):
32
        super(LabContactsView, self).__init__(context, request)
33
34
        self.catalog = "bika_setup_catalog"
35
        self.contentFilter = {
36
            "portal_type": "LabContact",
37
            "sort_on": "sortable_title",
38
            "sort_order": "ascending",
39
        }
40
41
        self.context_actions = {
42
            _("Add"): {
43
                "url": "createObject?type_name=LabContact",
44
                "permission": "Add portal content",
45
                "icon": "++resource++bika.lims.images/add.png"}
46
        }
47
48
        self.title = self.context.translate(_("Lab Contacts"))
49
        self.icon = "{}/{}".format(
50
            self.portal_url,
51
            "/++resource++bika.lims.images/lab_contact_big.png"
52
        )
53
54
        self.show_sort_column = False
55
        self.show_select_row = False
56
        self.show_select_column = True
57
        self.pagesize = 25
58
59
        self.columns = collections.OrderedDict((
60
            # TODO: Better sort by last name (index required!)
61
            ("Fullname", {
62
                "title": _("Name"),
63
                "index": "getFullname"}),
64
            ("Department", {
65
                "title": _("Department"),
66
                "toggle": True}),
67
            ("BusinessPhone", {
68
                "title": _("Phone"),
69
                "toggle": True}),
70
            ("Fax", {
71
                "title": _("Fax"),
72
                "toggle": False}),
73
            ("MobilePhone", {
74
                "title": _("Mobile Phone"),
75
                "toggle": True}),
76
            ("EmailAddress", {
77
                "title": _("Email Address"),
78
                "toggle": True}),
79
        ))
80
81
        self.review_states = [
82
            {
83
                "id": "default",
84
                "title": _("Active"),
85
                "contentFilter": {"inactive_state": "active"},
86
                "transitions": [{"id": "deactivate"}, ],
87
                "columns": self.columns.keys(),
88
            }, {
89
                "id": "inactive",
90
                "title": _("Dormant"),
91
                "contentFilter": {"inactive_state": "inactive"},
92
                "transitions": [{"id": "activate"}, ],
93
                "columns": self.columns.keys(),
94
            }, {
95
                "id": "all",
96
                "title": _("All"),
97
                "contentFilter": {},
98
                "columns": self.columns.keys(),
99
            },
100
        ]
101

bika/lims/controlpanel/bika_samplepoints.py 1 location

@@ 36-102 (lines=67) @@
33
class SamplePointsView(BikaListingView):
34
    implements(IFolderContentsView, IViewView)
35
36
    def __init__(self, context, request):
37
        super(SamplePointsView, self).__init__(context, request)
38
39
        self.catalog = "bika_setup_catalog"
40
        self.contentFilter = {
41
            "portal_type": "SamplePoint",
42
            "sort_on": "sortable_title",
43
            "sort_order": "ascending",
44
        }
45
46
        self.context_actions = {
47
            _("Add"): {
48
                "url": "createObject?type_name=SamplePoint",
49
                "permission": "Add portal content",
50
                "icon": "++resource++bika.lims.images/add.png"}
51
        }
52
53
        self.title = self.context.translate(_("Sample Points"))
54
        self.icon = "{}/{}".format(
55
            self.portal_url,
56
            "/++resource++bika.lims.images/samplepoint_big.png"
57
        )
58
        self.show_sort_column = False
59
        self.show_select_row = False
60
        self.show_select_column = True
61
        self.pagesize = 25
62
63
        self.columns = collections.OrderedDict((
64
            ("Title", {
65
                "title": _("Sample Point"),
66
                "index": "sortable_title"}),
67
            ("Description", {
68
                "title": _("Description"),
69
                "index": "Description",
70
                "toggle": True}),
71
            ("Owner", {
72
                "title": _p("Owner"),
73
                "sortable": False,
74
                "toggle": True}),
75
            ("getComposite", {
76
                "title": _("Composite"),
77
                "sortable": False,
78
                "toggle": False}),
79
            ("SampleTypes", {
80
                "title": _("Sample Types"),
81
                "index": "getSampleTypeTitle",
82
                "toggle": True}),
83
        ))
84
85
        self.review_states = [
86
            {
87
                "id": "default",
88
                "title": _("Active"),
89
                "contentFilter": {"inactive_state": "active"},
90
                "transitions": [{"id": "deactivate"}, ],
91
                "columns": self.columns.keys(),
92
            }, {
93
                "id": "inactive",
94
                "title": _("Dormant"),
95
                "contentFilter": {"inactive_state": "inactive"},
96
                "transitions": [{"id": "activate"}, ],
97
                "columns": self.columns.keys(),
98
            }, {
99
                "id": "all",
100
                "title": _("All"),
101
                "contentFilter": {},
102
                "columns": self.columns.keys(),
103
            }
104
        ]
105