Code Duplication    Length = 21-22 lines in 3 locations

bika/lims/content/analysisrequest.py 1 location

@@ 2003-2024 (lines=22) @@
2000
        """
2001
        return self.getContainer() and [self.getContainer] or []
2002
2003
    def isAnalysisServiceHidden(self, uid):
2004
        """Checks if the analysis service that match with the uid provided must
2005
        be hidden in results. If no hidden assignment has been set for the
2006
        analysis in this request, returns the visibility set to the analysis
2007
        itself.
2008
2009
        Raise a TypeError if the uid is empty or None
2010
2011
        Raise a ValueError if there is no hidden assignment in this request or
2012
        no analysis service found for this uid.
2013
        """
2014
        if not uid:
2015
            raise TypeError('None type or empty uid')
2016
        sets = self.getAnalysisServiceSettings(uid)
2017
        if 'hidden' not in sets:
2018
            uc = getToolByName(self, 'uid_catalog')
2019
            serv = uc(UID=uid)
2020
            if serv and len(serv) == 1:
2021
                return serv[0].getObject().getRawHidden()
2022
            else:
2023
                raise ValueError('{} is not valid'.format(uid))
2024
        return sets.get('hidden', False)
2025
2026
    def getRejecter(self):
2027
        """If the Analysis Request has been rejected, returns the user who did the

bika/lims/content/artemplate.py 1 location

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

bika/lims/content/analysisprofile.py 1 location

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