Пример #1
0
    def get_filtered_query(self, query):
        if self.request.can_access_all_locations and (EMWF.show_all_data(
                self.value) or EMWF.no_filters_selected(self.value)):
            return query

        if self.request.can_access_all_locations and EMWF.show_project_data(
                self.value):
            return query_all_project_data(query, self.domain, self.value)

        if self.request.can_access_all_locations and EMWF.show_deactivated_data(
                self.value):
            return query_deactivated_data(query, self.domain)

        # otherwise only return explicit matches
        case_owners = get_case_owners(self.request, self.domain, self.value)
        return query.owner(case_owners)
Пример #2
0
    def get_filtered_query(self, query):
        if self.request.can_access_all_locations and (
            EMWF.show_all_data(self.value)
            or EMWF.no_filters_selected(self.value)
        ):
            return query

        if self.request.can_access_all_locations and EMWF.show_project_data(self.value):
            return query_all_project_data(query, self.domain, self.value)

        if self.request.can_access_all_locations and EMWF.show_deactivated_data(self.value):
            return query_deactivated_data(query, self.domain)

        # otherwise only return explicit matches
        case_owners = get_case_owners(self.request, self.domain, self.value)
        return query.owner(case_owners)
Пример #3
0
    def _build_query(self):
        query = (self.search_class()
                 .domain(self.domain)
                 .size(self.pagination.count)
                 .start(self.pagination.start))
        query.es_query['sort'] = self.get_sorting_block()
        mobile_user_and_group_slugs = self.request.GET.getlist(EMWF.slug)

        if self.case_filter:
            query = query.filter(self.case_filter)

        query = query.NOT(case_es.case_type("user-owner-mapping-case"))

        if self.case_type:
            query = query.case_type(self.case_type)

        if self.case_status:
            query = query.is_closed(self.case_status == 'closed')

        if self.request.can_access_all_locations and (
                EMWF.show_all_data(mobile_user_and_group_slugs)
                or EMWF.no_filters_selected(mobile_user_and_group_slugs)
        ):
            pass

        elif (self.request.can_access_all_locations
              and EMWF.show_project_data(mobile_user_and_group_slugs)):
            query = query_all_project_data(
                query, self.domain, mobile_user_and_group_slugs
            )

        elif (self.request.can_access_all_locations
              and EMWF.show_deactivated_data(mobile_user_and_group_slugs)):
            query = query_deactivated_data(query, self.domain)

        else:  # Only show explicit matches
            query = query.owner(self.case_owners)

        if not self.request.can_access_all_locations:
            query = query_location_restricted_cases(query, self.request)

        search_string = CaseSearchFilter.get_value(self.request, self.domain)
        if search_string:
            query = query.set_query({"query_string": {"query": search_string}})

        return query
Пример #4
0
    def _build_query(self):
        query = (self.search_class()
                 .domain(self.domain)
                 .size(self.pagination.count)
                 .start(self.pagination.start))
        query.es_query['sort'] = self.get_sorting_block()
        mobile_user_and_group_slugs = self.request.GET.getlist(EMWF.slug)

        if self.case_filter:
            query = query.filter(self.case_filter)

        query = query.NOT(case_es.case_type("user-owner-mapping-case"))

        if self.case_type:
            query = query.case_type(self.case_type)

        if self.case_status:
            query = query.is_closed(self.case_status == 'closed')

        if self.request.can_access_all_locations and (
                EMWF.show_all_data(mobile_user_and_group_slugs)
                or EMWF.no_filters_selected(mobile_user_and_group_slugs)
        ):
            pass

        elif (self.request.can_access_all_locations
              and EMWF.show_project_data(mobile_user_and_group_slugs)):
            query = query_all_project_data(
                query, self.domain, mobile_user_and_group_slugs
            )

        elif (self.request.can_access_all_locations
              and EMWF.show_deactivated_data(mobile_user_and_group_slugs)):
            query = query_deactivated_data(query, self.domain)

        else:  # Only show explicit matches
            query = query.owner(self.case_owners)

        if not self.request.can_access_all_locations:
            query = query_location_restricted_cases(query, self.request)

        search_string = CaseSearchFilter.get_value(self.request, self.domain)
        if search_string:
            query = query.set_query({"query_string": {"query": search_string}})

        return query
Пример #5
0
    def get_filtered_query(self, query):
        if self.request.can_access_all_locations and (EMWF.show_all_data(
                self.value) or EMWF.no_filters_selected(self.value)):
            return query

        if self.request.can_access_all_locations and EMWF.show_project_data(
                self.value):
            return query_all_project_data(query, self.domain, self.value)

        if self.request.can_access_all_locations and EMWF.show_deactivated_data(
                self.value):
            return query_deactivated_data(query, self.domain)

        selected_user_types = [v['id'] for v in self.value]
        case_owners = get_case_owners(self.request, self.domain,
                                      selected_user_types)
        return query.owner(case_owners)