Code Duplication    Length = 75-77 lines in 2 locations

bika/lims/browser/instrument.py 2 locations

@@ 35-111 (lines=77) @@
32
    """Listing view for instrument maintenance tasks
33
    """
34
35
    def __init__(self, context, request):
36
        super(InstrumentMaintenanceView, self).__init__(context, request)
37
        self.catalog = "portal_catalog"
38
        self.contentFilter = {
39
            "portal_type": "InstrumentMaintenanceTask",
40
            "path": {
41
                "query": api.get_path(context),
42
                "depth": 1  # searching just inside the specified folder
43
            },
44
            "sort_on": "created",
45
            "sort_order": "descending",
46
        }
47
48
        self.form_id = "instrumentmaintenance"
49
        self.title = self.context.translate(_("Instrument Maintenance"))
50
51
        self.icon = "{}/{}".format(
52
            self.portal_url,
53
            "++resource++bika.lims.images/instrumentmaintenance_big.png"
54
        )
55
        self.context_actions = {
56
            _("Add"): {
57
                "url": "createObject?type_name=InstrumentMaintenanceTask",
58
                "icon": "++resource++bika.lims.images/add.png"}
59
        }
60
61
        self.allow_edit = False
62
        self.show_select_column = False
63
        self.show_workflow_action_buttons = True
64
        self.pagesize = 30
65
66
        self.columns = {
67
            'getCurrentState': {'title': ''},
68
            'Title': {'title': _('Task'),
69
                      'index': 'sortable_title'},
70
            'getType': {'title': _('Task type', 'Type'), 'sortable': True},
71
            'getDownFrom': {'title': _('Down from'), 'sortable': True},
72
            'getDownTo': {'title': _('Down to'), 'sortable': True},
73
            'getMaintainer': {'title': _('Maintainer'), 'sortable': True},
74
        }
75
76
        self.review_states = [
77
            {
78
                "id": "default",
79
                "title": _("Open"),
80
                "contentFilter": {"cancellation_state": "active"},
81
                "columns": [
82
                    "getCurrentState",
83
                    "Title",
84
                    "getType",
85
                    "getDownFrom",
86
                    "getDownTo",
87
                    "getMaintainer",
88
                ]
89
            }, {
90
                "id": "cancelled",
91
                "title": _("Cancelled"),
92
                "contentFilter": {"cancellation_state": "cancelled"},
93
                "columns": [
94
                    "getCurrentState",
95
                    "Title",
96
                    "getType",
97
                    "getDownFrom",
98
                    "getDownTo",
99
                    "getMaintainer",
100
                ]
101
            }, {
102
                "id": "all",
103
                "title": _("All"),
104
                "contentFilter": {},
105
                "columns": [
106
                    "getCurrentState",
107
                    "Title",
108
                    "getType",
109
                    "getDownFrom",
110
                    "getDownTo",
111
                    "getMaintainer"
112
                ]
113
            }
114
        ]
@@ 349-423 (lines=75) @@
346
    """Listing view for instrument scheduled tasks
347
    """
348
349
    def __init__(self, context, request):
350
        super(InstrumentScheduleView, self).__init__(context, request)
351
        self.catalog = "portal_catalog"
352
        self.contentFilter = {
353
            "portal_type": "InstrumentScheduledTask",
354
            "path": {
355
                "query": api.get_path(context),
356
                "depth": 1  # searching just inside the specified folder
357
            },
358
            "sort_on": "created",
359
            "sort_order": "descending",
360
        }
361
362
        self.form_id = "instrumentschedule"
363
        self.title = self.context.translate(_("Instrument Scheduled Tasks"))
364
365
        self.icon = "{}/{}".format(
366
            self.portal_url,
367
            "++resource++bika.lims.images/instrumentschedule_big.png"
368
        )
369
        self.context_actions = {
370
            _("Add"): {
371
                "url": "createObject?type_name=InstrumentScheduledTask",
372
                "icon": "++resource++bika.lims.images/add.png"}
373
        }
374
375
        self.allow_edit = False
376
        self.show_select_column = False
377
        self.show_workflow_action_buttons = True
378
        self.pagesize = 30
379
380
        self.columns = {
381
            "Title": {"title": _("Scheduled task"),
382
                      "index": "sortable_title"},
383
            "getType": {"title": _("Task type", "Type")},
384
            "getCriteria": {"title": _("Criteria")},
385
            "creator": {"title": _("Created by")},
386
            "created": {"title": _("Created")},
387
        }
388
389
        self.review_states = [
390
            {
391
                "id": "default",
392
                "title": _("Active"),
393
                "contentFilter": {"inactive_state": "active"},
394
                "transitions": [{"id": "deactivate"}, ],
395
                "columns": [
396
                    "Title",
397
                    "getType",
398
                    "getCriteria",
399
                    "creator",
400
                    "created",
401
                ]
402
            }, {
403
                "id": "inactive",
404
                "title": _("Dormant"),
405
                "contentFilter": {"inactive_state": "inactive"},
406
                "transitions": [{"id": "activate"}, ],
407
                "columns": [
408
                    "Title",
409
                    "getType",
410
                    "getCriteria",
411
                    "creator",
412
                    "created"
413
                ]
414
            }, {
415
                "id": "all",
416
                "title": _("All"),
417
                "contentFilter": {},
418
                "columns": [
419
                    "Title",
420
                    "getType",
421
                    "getCriteria",
422
                    "creator",
423
                    "created",
424
                ]
425
            }
426
        ]