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

@@ 2085-2106 (lines=22) @@
2082
        """
2083
        return self.getContainer() and [self.getContainer] or []
2084
2085
    def isAnalysisServiceHidden(self, uid):
2086
        """Checks if the analysis service that match with the uid provided must
2087
        be hidden in results. If no hidden assignment has been set for the
2088
        analysis in this request, returns the visibility set to the analysis
2089
        itself.
2090
2091
        Raise a TypeError if the uid is empty or None
2092
2093
        Raise a ValueError if there is no hidden assignment in this request or
2094
        no analysis service found for this uid.
2095
        """
2096
        if not uid:
2097
            raise TypeError('None type or empty uid')
2098
        sets = self.getAnalysisServiceSettings(uid)
2099
        if 'hidden' not in sets:
2100
            uc = getToolByName(self, 'uid_catalog')
2101
            serv = uc(UID=uid)
2102
            if serv and len(serv) == 1:
2103
                return serv[0].getObject().getRawHidden()
2104
            else:
2105
                raise ValueError('{} is not valid'.format(uid))
2106
        return sets.get('hidden', False)
2107
2108
    def getRejecter(self):
2109
        """If the Analysis Request has been rejected, returns the user who did the