Exemple #1
0
    def cases(self):
        if 'debug_case' in self.request.GET:
            case = CommCareCase.get(self.request.GET['debug_case'])
            if case.domain != DOMAIN:
                raise Http404()
            return [case]

        query = case_es.CaseES().domain(self.domain)\
                .fields([])\
                .opened_range(lte=self.datespan.enddate_utc)\
                .case_type(self.default_case_type)
        query.index = 'report_cases'

        if self.case_status == 'open':
            query = query.filter(es_filters.OR(
                case_es.is_closed(False),
                case_es.closed_range(gte=self.datespan.enddate_utc)
            ))
        elif self.case_status == 'closed':
            query = query.filter(case_es.closed_range(lte=self.datespan.enddate_utc))

        query = query.owner([user['doc_id'] for user in self.users_matching_filter])

        result = query.run()

        return [
            CommCareCase.wrap(doc)
            for doc in iter_docs(CommCareCase.get_db(), result.ids)
        ]
Exemple #2
0
    def get_rows(self):
        query = case_es.CaseES().domain(self.domain)\
                .fields([])\
                .opened_range(lte=self.datespan.enddate_utc)\
                .case_type(self.default_case_type)
        query.index = 'report_cases'

        if self.case_status == 'open':
            query = query.filter(es_filters.OR(
                case_es.is_closed(False),
                case_es.closed_range(gte=self.datespan.enddate_utc)
            ))
        elif self.case_status == 'closed':
            query = query.filter(case_es.closed_range(lte=self.datespan.enddate_utc))

        query = query.owner([user['doc_id'] for user in self.users_matching_filter])

        result = query.run()

        return [
            CommCareCase.wrap(doc)
            for doc in iter_docs(CommCareCase.get_db(), result.ids)
        ]