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

@@ 2716-2737 (lines=22) @@
2713
                containers.append(partition.getContainer())
2714
        return containers
2715
2716
    def isAnalysisServiceHidden(self, uid):
2717
        """Checks if the analysis service that match with the uid provided must
2718
        be hidden in results. If no hidden assignment has been set for the
2719
        analysis in this request, returns the visibility set to the analysis
2720
        itself.
2721
2722
        Raise a TypeError if the uid is empty or None
2723
2724
        Raise a ValueError if there is no hidden assignment in this request or
2725
        no analysis service found for this uid.
2726
        """
2727
        if not uid:
2728
            raise TypeError('None type or empty uid')
2729
        sets = self.getAnalysisServiceSettings(uid)
2730
        if 'hidden' not in sets:
2731
            uc = getToolByName(self, 'uid_catalog')
2732
            serv = uc(UID=uid)
2733
            if serv and len(serv) == 1:
2734
                return serv[0].getObject().getRawHidden()
2735
            else:
2736
                raise ValueError('{} is not valid'.format(uid))
2737
        return sets.get('hidden', False)
2738
2739
    def getRejecter(self):
2740
        """If the Analysis Request has been rejected, returns the user who did the