Code Duplication    Length = 21-22 lines in 3 locations

bika/lims/content/analysisprofile.py 1 location

@@ 159-179 (lines=21) @@
156
                if s.get('uid','') == uid]
157
        return sets[0] if sets else {'uid': uid}
158
159
    def isAnalysisServiceHidden(self, uid):
160
        """ Checks if the analysis service that match with the uid
161
            provided must be hidden in results.
162
            If no hidden assignment has been set for the analysis in
163
            this profile, returns the visibility set to the analysis
164
            itself.
165
            Raise a TypeError if the uid is empty or None
166
            Raise a ValueError if there is no hidden assignment in this
167
                profile or no analysis service found for this uid.
168
        """
169
        if not uid:
170
            raise TypeError('None type or empty uid')
171
        sets = self.getAnalysisServiceSettings(uid)
172
        if 'hidden' not in sets:
173
            uc = getToolByName(self, 'uid_catalog')
174
            serv = uc(UID=uid)
175
            if serv and len(serv) == 1:
176
                return serv[0].getObject().getRawHidden()
177
            else:
178
                raise ValueError('%s is not valid' % uid)
179
        return sets.get('hidden', False)
180
181
    def getVATAmount(self):
182
        """ Compute AnalysisProfileVATAmount

bika/lims/content/artemplate.py 1 location

@@ 243-263 (lines=21) @@
240
                if s.get('uid','') == uid]
241
        return sets[0] if sets else {'uid': uid}
242
243
    def isAnalysisServiceHidden(self, uid):
244
        """ Checks if the analysis service that match with the uid
245
            provided must be hidden in results.
246
            If no hidden assignment has been set for the analysis in
247
            this template, returns the visibility set to the analysis
248
            itself.
249
            Raise a TypeError if the uid is empty or None
250
            Raise a ValueError if there is no hidden assignment in this
251
                template or no analysis service found for this uid.
252
        """
253
        if not uid:
254
            raise TypeError('None type or empty uid')
255
        sets = self.getAnalysisServiceSettings(uid)
256
        if 'hidden' not in sets:
257
            uc = getToolByName(self, 'uid_catalog')
258
            serv = uc(UID=uid)
259
            if serv and len(serv) == 1:
260
                return serv[0].getObject().getRawHidden()
261
            else:
262
                raise ValueError('%s is not valid' % uid)
263
        return sets.get('hidden', False)
264
265
266
    def remove_service(self, service):

bika/lims/content/analysisrequest.py 1 location

@@ 2698-2719 (lines=22) @@
2695
                containers.append(partition.getContainer())
2696
        return containers
2697
2698
    def isAnalysisServiceHidden(self, uid):
2699
        """Checks if the analysis service that match with the uid provided must
2700
        be hidden in results. If no hidden assignment has been set for the
2701
        analysis in this request, returns the visibility set to the analysis
2702
        itself.
2703
2704
        Raise a TypeError if the uid is empty or None
2705
2706
        Raise a ValueError if there is no hidden assignment in this request or
2707
        no analysis service found for this uid.
2708
        """
2709
        if not uid:
2710
            raise TypeError('None type or empty uid')
2711
        sets = self.getAnalysisServiceSettings(uid)
2712
        if 'hidden' not in sets:
2713
            uc = getToolByName(self, 'uid_catalog')
2714
            serv = uc(UID=uid)
2715
            if serv and len(serv) == 1:
2716
                return serv[0].getObject().getRawHidden()
2717
            else:
2718
                raise ValueError('{} is not valid'.format(uid))
2719
        return sets.get('hidden', False)
2720
2721
    def getRejecter(self):
2722
        """If the Analysis Request has been rejected, returns the user who did the