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

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