Passed
Push — master ( b9e514...257903 )
by Jordi
11:51 queued 05:38
created

bika.lims.monkey.zcatalog.searchResults()   A

Complexity

Conditions 4

Size

Total Lines 24
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 24
rs 9.95
c 0
b 0
f 0
cc 4
nop 4
1
# -*- coding: utf-8 -*-
2
#
3
# This file is part of SENAITE.CORE.
4
#
5
# SENAITE.CORE is free software: you can redistribute it and/or modify it under
6
# the terms of the GNU General Public License as published by the Free Software
7
# Foundation, version 2.
8
#
9
# This program is distributed in the hope that it will be useful, but WITHOUT
10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12
# details.
13
#
14
# You should have received a copy of the GNU General Public License along with
15
# this program; if not, write to the Free Software Foundation, Inc., 51
16
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
#
18
# Copyright 2018-2019 by it's authors.
19
# Some rights reserved, see README and LICENSE.
20
21
from bika.lims.catalog.analysis_catalog import CATALOG_ANALYSIS_LISTING
22
23
24
def searchResults(self, REQUEST=None, used=None, **kw):
25
    """Search the catalog
26
27
    Search terms can be passed in the REQUEST or as keyword
28
    arguments.
29
30
    The used argument is now deprecated and ignored
31
    """
32
    if REQUEST and REQUEST.get('getRequestUID') \
33
            and self.id == CATALOG_ANALYSIS_LISTING:
34
35
        # Fetch all analyses that have the request UID passed in as an ancestor,
36
        # cause we want for Samples to always return the contained analyses plus
37
        # those contained in partitions
38
        request = REQUEST.copy()
39
        orig_uid = request.get('getRequestUID')
40
41
        # Get all analyses, those from descendant ARs included
42
        del request['getRequestUID']
43
        request['getAncestorsUIDs'] = orig_uid
44
        return self.searchResults(REQUEST=request, used=used, **kw)
45
46
    # Normal search
47
    return self._catalog.searchResults(REQUEST, used, **kw)
48