Code Duplication    Length = 10-19 lines in 5 locations

bika/lims/content/labcontact.py 2 locations

@@ 118-136 (lines=19) @@
115
        items.sort(lambda x, y: cmp(x[1], y[1]))
116
        return DisplayList(list(items))
117
118
    def _departmentsVoc(self):
119
        """
120
        Returns a vocabulary object with the available departments.
121
        """
122
        bsc = getToolByName(self, 'bika_setup_catalog')
123
        items = [(o.UID, o.Title) for o in
124
                 bsc(portal_type='Department',
125
                     is_active=True)]
126
        # Getting the departments uids
127
        deps_uids = [i[0] for i in items]
128
        # Getting the assigned departments
129
        objs = self.getDepartments()
130
        # If one department assigned to the Lab Contact is disabled, it will
131
        # be shown in the list until the department has been unassigned.
132
        for o in objs:
133
            if o and o.UID() not in deps_uids:
134
                items.append((o.UID(), o.Title()))
135
        items.sort(lambda x, y: cmp(x[1], y[1]))
136
        return DisplayList(list(items))
137
138
    def _defaultDepsVoc(self):
139
        """
@@ 98-116 (lines=19) @@
95
        return self.portal_membership.getMemberById(
96
            self.getUsername()) is not None
97
98
    def getDepartments_voc(self):
99
        """
100
        Returns a vocabulary object with the available departments.
101
        """
102
        bsc = getToolByName(self, 'portal_catalog')
103
        items = [(o.UID, o.Title) for o in
104
                 bsc(portal_type='Department',
105
                     is_active=True)]
106
        # Getting the departments uids
107
        deps_uids = [i[0] for i in items]
108
        # Getting the assigned departments
109
        objs = self.getDepartments()
110
        # If one department assigned to the Lab Contact is disabled, it will
111
        # be shown in the list until the department has been unassigned.
112
        for o in objs:
113
            if o and o.UID() not in deps_uids:
114
                items.append((o.UID(), o.Title()))
115
        items.sort(lambda x, y: cmp(x[1], y[1]))
116
        return DisplayList(list(items))
117
118
    def _departmentsVoc(self):
119
        """

bika/lims/content/srtemplate.py 1 location

@@ 110-123 (lines=14) @@
107
        """
108
        return getUsers(self, ['LabManager', 'Sampler'])
109
110
    def _getDepartmentsDisplayList(self):
111
        """ Returns the available departments in the system. Only the
112
            active departments are shown, unless the object has an
113
            inactive department already assigned.
114
        """
115
        bsc = getToolByName(self, 'bika_setup_catalog')
116
        items = [('', '')] + [(o.UID, o.Title) for o in
117
                              bsc(portal_type='Department',
118
                                  is_active=True)]
119
        o = self.getDepartment()
120
        if o and o.UID() not in [i[0] for i in items]:
121
            items.append((o.UID(), o.Title()))
122
        items.sort(lambda x, y: cmp(x[1], y[1]))
123
        return DisplayList(list(items))
124
125
126
registerType(SRTemplate, PROJECTNAME)

bika/lims/content/referencesample.py 1 location

@@ 206-215 (lines=10) @@
203
        items.sort(lambda x,y: cmp(x[1], y[1]))
204
        return DisplayList(list(items))
205
206
    def getManufacturers(self):
207
        bsc = getToolByName(self, 'bika_setup_catalog')
208
        items = [('','')] + [(o.UID, o.Title) for o in
209
                               bsc(portal_type='Manufacturer',
210
                                   is_active = True)]
211
        o = self.getReferenceDefinition()
212
        if o and o.UID() not in [i[0] for i in items]:
213
            items.append((o.UID(), o.Title()))
214
        items.sort(lambda x,y: cmp(x[1], y[1]))
215
        return DisplayList(list(items))
216
217
    security.declarePublic('getResultsRangeDict')
218
    def getResultsRangeDict(self):

bika/lims/content/abstractbaseanalysis.py 1 location

@@ 824-836 (lines=13) @@
821
        items.sort(lambda x, y: cmp(x[1], y[1]))
822
        return DisplayList(list(items))
823
824
    @security.public
825
    def getDepartments(self):
826
        """A vocabulary listing available (and activated) departments.
827
        """
828
        bsc = getToolByName(self, 'bika_setup_catalog')
829
        items = [('', '')] + [(o.UID, o.Title) for o in
830
                              bsc(portal_type='Department',
831
                                  is_active=True)]
832
        o = self.getDepartment()
833
        if o and o.UID() not in [i[0] for i in items]:
834
            items.append((o.UID(), o.Title()))
835
        items.sort(lambda x, y: cmp(x[1], y[1]))
836
        return DisplayList(list(items))
837
838
    @security.public
839
    def getLowerDetectionLimit(self):