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

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