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

@@ 1990-2011 (lines=22) @@
1987
        """
1988
        return self.getContainer() and [self.getContainer] or []
1989
1990
    def isAnalysisServiceHidden(self, uid):
1991
        """Checks if the analysis service that match with the uid provided must
1992
        be hidden in results. If no hidden assignment has been set for the
1993
        analysis in this request, returns the visibility set to the analysis
1994
        itself.
1995
1996
        Raise a TypeError if the uid is empty or None
1997
1998
        Raise a ValueError if there is no hidden assignment in this request or
1999
        no analysis service found for this uid.
2000
        """
2001
        if not uid:
2002
            raise TypeError('None type or empty uid')
2003
        sets = self.getAnalysisServiceSettings(uid)
2004
        if 'hidden' not in sets:
2005
            uc = getToolByName(self, 'uid_catalog')
2006
            serv = uc(UID=uid)
2007
            if serv and len(serv) == 1:
2008
                return serv[0].getObject().getRawHidden()
2009
            else:
2010
                raise ValueError('{} is not valid'.format(uid))
2011
        return sets.get('hidden', False)
2012
2013
    def getRejecter(self):
2014
        """If the Analysis Request has been rejected, returns the user who did the