Code Duplication    Length = 21-22 lines in 3 locations

bika/lims/content/analysisprofile.py 1 location

@@ 159-179 (lines=21) @@
156
                if s.get('uid','') == uid]
157
        return sets[0] if sets else {'uid': uid}
158
159
    def isAnalysisServiceHidden(self, uid):
160
        """ Checks if the analysis service that match with the uid
161
            provided must be hidden in results.
162
            If no hidden assignment has been set for the analysis in
163
            this profile, returns the visibility set to the analysis
164
            itself.
165
            Raise a TypeError if the uid is empty or None
166
            Raise a ValueError if there is no hidden assignment in this
167
                profile or no analysis service found for this uid.
168
        """
169
        if not uid:
170
            raise TypeError('None type or empty uid')
171
        sets = self.getAnalysisServiceSettings(uid)
172
        if 'hidden' not in sets:
173
            uc = getToolByName(self, 'uid_catalog')
174
            serv = uc(UID=uid)
175
            if serv and len(serv) == 1:
176
                return serv[0].getObject().getRawHidden()
177
            else:
178
                raise ValueError('%s is not valid' % uid)
179
        return sets.get('hidden', False)
180
181
    def getVATAmount(self):
182
        """ Compute AnalysisProfileVATAmount

bika/lims/content/artemplate.py 1 location

@@ 316-336 (lines=21) @@
313
        sets = [s for s in settings if s.get("uid", "") == uid]
314
        return sets[0] if sets else {"uid": uid}
315
316
    def isAnalysisServiceHidden(self, uid):
317
        """ Checks if the analysis service that match with the uid
318
            provided must be hidden in results.
319
            If no hidden assignment has been set for the analysis in
320
            this template, returns the visibility set to the analysis
321
            itself.
322
            Raise a TypeError if the uid is empty or None
323
            Raise a ValueError if there is no hidden assignment in this
324
                template or no analysis service found for this uid.
325
        """
326
        if not uid:
327
            raise TypeError("None type or empty uid")
328
        sets = self.getAnalysisServiceSettings(uid)
329
        if "hidden" not in sets:
330
            uc = getToolByName(self, "uid_catalog")
331
            serv = uc(UID=uid)
332
            if serv and len(serv) == 1:
333
                return serv[0].getObject().getRawHidden()
334
            else:
335
                raise ValueError("%s is not valid" % uid)
336
        return sets.get("hidden", False)
337
338
    def remove_service(self, service):
339
        """Removes the service passed in from the services offered by the

bika/lims/content/analysisrequest.py 1 location

@@ 2621-2642 (lines=22) @@
2618
                containers.append(partition.getContainer())
2619
        return containers
2620
2621
    def isAnalysisServiceHidden(self, uid):
2622
        """Checks if the analysis service that match with the uid provided must
2623
        be hidden in results. If no hidden assignment has been set for the
2624
        analysis in this request, returns the visibility set to the analysis
2625
        itself.
2626
2627
        Raise a TypeError if the uid is empty or None
2628
2629
        Raise a ValueError if there is no hidden assignment in this request or
2630
        no analysis service found for this uid.
2631
        """
2632
        if not uid:
2633
            raise TypeError('None type or empty uid')
2634
        sets = self.getAnalysisServiceSettings(uid)
2635
        if 'hidden' not in sets:
2636
            uc = getToolByName(self, 'uid_catalog')
2637
            serv = uc(UID=uid)
2638
            if serv and len(serv) == 1:
2639
                return serv[0].getObject().getRawHidden()
2640
            else:
2641
                raise ValueError('{} is not valid'.format(uid))
2642
        return sets.get('hidden', False)
2643
2644
    def getRejecter(self):
2645
        """If the Analysis Request has been rejected, returns the user who did the