Code Duplication    Length = 21-22 lines in 3 locations

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

bika/lims/content/analysisrequest.py 1 location

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