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

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

bika/lims/content/analysisrequest.py 1 location

@@ 2028-2049 (lines=22) @@
2025
        """
2026
        return self.getContainer() and [self.getContainer] or []
2027
2028
    def isAnalysisServiceHidden(self, uid):
2029
        """Checks if the analysis service that match with the uid provided must
2030
        be hidden in results. If no hidden assignment has been set for the
2031
        analysis in this request, returns the visibility set to the analysis
2032
        itself.
2033
2034
        Raise a TypeError if the uid is empty or None
2035
2036
        Raise a ValueError if there is no hidden assignment in this request or
2037
        no analysis service found for this uid.
2038
        """
2039
        if not uid:
2040
            raise TypeError('None type or empty uid')
2041
        sets = self.getAnalysisServiceSettings(uid)
2042
        if 'hidden' not in sets:
2043
            uc = getToolByName(self, 'uid_catalog')
2044
            serv = uc(UID=uid)
2045
            if serv and len(serv) == 1:
2046
                return serv[0].getObject().getRawHidden()
2047
            else:
2048
                raise ValueError('{} is not valid'.format(uid))
2049
        return sets.get('hidden', False)
2050
2051
    def getRejecter(self):
2052
        """If the Analysis Request has been rejected, returns the user who did the