Code Duplication    Length = 21-22 lines in 3 locations

bika/lims/content/analysisrequest.py 1 location

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

bika/lims/content/artemplate.py 1 location

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

bika/lims/content/analysisprofile.py 1 location

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