Code Duplication    Length = 21-22 lines in 3 locations

src/bika/lims/content/artemplate.py 1 location

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

src/bika/lims/content/analysisprofile.py 1 location

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

src/bika/lims/content/analysisrequest.py 1 location

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