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

@@ 2650-2671 (lines=22) @@
2647
                containers.append(partition.getContainer())
2648
        return containers
2649
2650
    def isAnalysisServiceHidden(self, uid):
2651
        """Checks if the analysis service that match with the uid provided must
2652
        be hidden in results. If no hidden assignment has been set for the
2653
        analysis in this request, returns the visibility set to the analysis
2654
        itself.
2655
2656
        Raise a TypeError if the uid is empty or None
2657
2658
        Raise a ValueError if there is no hidden assignment in this request or
2659
        no analysis service found for this uid.
2660
        """
2661
        if not uid:
2662
            raise TypeError('None type or empty uid')
2663
        sets = self.getAnalysisServiceSettings(uid)
2664
        if 'hidden' not in sets:
2665
            uc = getToolByName(self, 'uid_catalog')
2666
            serv = uc(UID=uid)
2667
            if serv and len(serv) == 1:
2668
                return serv[0].getObject().getRawHidden()
2669
            else:
2670
                raise ValueError('{} is not valid'.format(uid))
2671
        return sets.get('hidden', False)
2672
2673
    def getRejecter(self):
2674
        """If the Analysis Request has been rejected, returns the user who did the