Code Duplication    Length = 21-22 lines in 3 locations

bika/lims/content/analysisrequest.py 1 location

@@ 2049-2070 (lines=22) @@
2046
        """
2047
        return self.getContainer() and [self.getContainer] or []
2048
2049
    def isAnalysisServiceHidden(self, uid):
2050
        """Checks if the analysis service that match with the uid provided must
2051
        be hidden in results. If no hidden assignment has been set for the
2052
        analysis in this request, returns the visibility set to the analysis
2053
        itself.
2054
2055
        Raise a TypeError if the uid is empty or None
2056
2057
        Raise a ValueError if there is no hidden assignment in this request or
2058
        no analysis service found for this uid.
2059
        """
2060
        if not uid:
2061
            raise TypeError('None type or empty uid')
2062
        sets = self.getAnalysisServiceSettings(uid)
2063
        if 'hidden' not in sets:
2064
            uc = getToolByName(self, 'uid_catalog')
2065
            serv = uc(UID=uid)
2066
            if serv and len(serv) == 1:
2067
                return serv[0].getObject().getRawHidden()
2068
            else:
2069
                raise ValueError('{} is not valid'.format(uid))
2070
        return sets.get('hidden', False)
2071
2072
    def getRejecter(self):
2073
        """If the Analysis Request has been rejected, returns the user who did the

bika/lims/content/artemplate.py 1 location

@@ 337-357 (lines=21) @@
334
        sets = [s for s in settings if s.get("uid", "") == uid]
335
        return sets[0] if sets else {"uid": uid}
336
337
    def isAnalysisServiceHidden(self, uid):
338
        """ Checks if the analysis service that match with the uid
339
            provided must be hidden in results.
340
            If no hidden assignment has been set for the analysis in
341
            this template, returns the visibility set to the analysis
342
            itself.
343
            Raise a TypeError if the uid is empty or None
344
            Raise a ValueError if there is no hidden assignment in this
345
                template or no analysis service found for this uid.
346
        """
347
        if not uid:
348
            raise TypeError("None type or empty uid")
349
        sets = self.getAnalysisServiceSettings(uid)
350
        if "hidden" not in sets:
351
            uc = getToolByName(self, "uid_catalog")
352
            serv = uc(UID=uid)
353
            if serv and len(serv) == 1:
354
                return serv[0].getObject().getRawHidden()
355
            else:
356
                raise ValueError("%s is not valid" % uid)
357
        return sets.get("hidden", False)
358
359
    def remove_service(self, service):
360
        """Removes the service passed in from the services offered by the

bika/lims/content/analysisprofile.py 1 location

@@ 180-200 (lines=21) @@
177
                if s.get('uid','') == uid]
178
        return sets[0] if sets else {'uid': uid}
179
180
    def isAnalysisServiceHidden(self, uid):
181
        """ Checks if the analysis service that match with the uid
182
            provided must be hidden in results.
183
            If no hidden assignment has been set for the analysis in
184
            this profile, returns the visibility set to the analysis
185
            itself.
186
            Raise a TypeError if the uid is empty or None
187
            Raise a ValueError if there is no hidden assignment in this
188
                profile or no analysis service found for this uid.
189
        """
190
        if not uid:
191
            raise TypeError('None type or empty uid')
192
        sets = self.getAnalysisServiceSettings(uid)
193
        if 'hidden' not in sets:
194
            uc = getToolByName(self, 'uid_catalog')
195
            serv = uc(UID=uid)
196
            if serv and len(serv) == 1:
197
                return serv[0].getObject().getRawHidden()
198
            else:
199
                raise ValueError('%s is not valid' % uid)
200
        return sets.get('hidden', False)
201
202
    def getVATAmount(self):
203
        """ Compute AnalysisProfileVATAmount