Beispiel #1
0
    def rows(self):
        formatter = DataFormatter(DictDataFormat(self.columns, no_value=self.no_value))
        data = formatter.format(self.data, keys=self.keys, group_by=self.group_by)

        selected_location = location_filter(self.request, location_filter_selected=True)
        selected_hierarchy = []
        if selected_location:
            selected_hierarchy = SQLLocation.objects.get(
                location_id=selected_location
            ).get_descendants(
                include_self=True
            ).filter(
                location_type__code='centre-de-sante'
            ).values_list(
                'location_id',
                flat=True
            )

        locations = SQLLocation.objects.filter(
            domain=self.domain,
            location_type__code='zone',
            is_archived=False
        ).order_by('name')
        user_locations = users_locations()
        for zone in locations:
            for reg in zone.children.order_by('name'):
                for dis in reg.children.order_by('name'):
                    for site in dis.children.order_by('name'):
                        row = data.get(site.location_id, {})
                        if show_location(site, user_locations, selected_hierarchy):
                            yield [
                                reg.name,
                                dis.name,
                                site.name,
                                row.get('cas_vus_5', EMPTY_CELL),
                                row.get('cas_suspects_5', EMPTY_CELL),
                                row.get('cas_confirmes_5', EMPTY_CELL),
                                row.get('cas_vus_5_10', EMPTY_CELL),
                                row.get('cas_suspects_5_10', EMPTY_CELL),
                                row.get('cas_confirmes_5_10', EMPTY_CELL),
                                row.get('cas_vus_10', EMPTY_CELL),
                                row.get('cas_suspects_10', EMPTY_CELL),
                                row.get('cas_confirmes_10', EMPTY_CELL),
                                row.get('cas_vus_fe', EMPTY_CELL),
                                row.get('cas_suspects_fe', EMPTY_CELL),
                                row.get('cas_confirmes_fe', EMPTY_CELL),
                                row.get('total_cas', EMPTY_CELL),
                                row.get('per_cas_5', EMPTY_CELL),
                                row.get('per_cas_5_10', EMPTY_CELL),
                                row.get('per_cas_10', EMPTY_CELL),
                                row.get('per_cas_fa', EMPTY_CELL),
                                zone.name
                            ]
Beispiel #2
0
    def rows(self):
        formatter = DataFormatter(DictDataFormat(self.columns, no_value=self.no_value))
        data = formatter.format(self.data, keys=self.keys, group_by=self.group_by)

        selected_location = location_filter(self.request, location_filter_selected=True)
        selected_hierarchy = []
        if selected_location:
            selected_hierarchy = SQLLocation.objects.get(
                location_id=selected_location
            ).get_descendants(
                include_self=True
            ).filter(
                location_type__code='centre-de-sante'
            ).values_list(
                'location_id',
                flat=True
            )

        locations = SQLLocation.objects.filter(
            domain=self.domain,
            location_type__code='zone',
            is_archived=False
        ).order_by('name')
        user_locations = users_locations()
        for zone in locations:
            for reg in zone.children.order_by('name'):
                for dis in reg.children.order_by('name'):
                    for site in dis.children.order_by('name'):
                        row = data.get(site.location_id, {})
                        if show_location(site, user_locations, selected_hierarchy):
                            yield [
                                reg.name,
                                dis.name,
                                site.name,
                                row.get('cas_vus_5', EMPTY_CELL),
                                row.get('cas_suspects_5', EMPTY_CELL),
                                row.get('cas_confirmes_5', EMPTY_CELL),
                                row.get('cas_vus_5_10', EMPTY_CELL),
                                row.get('cas_suspects_5_10', EMPTY_CELL),
                                row.get('cas_confirmes_5_10', EMPTY_CELL),
                                row.get('cas_vus_10', EMPTY_CELL),
                                row.get('cas_suspects_10', EMPTY_CELL),
                                row.get('cas_confirmes_10', EMPTY_CELL),
                                row.get('cas_vus_fe', EMPTY_CELL),
                                row.get('cas_suspects_fe', EMPTY_CELL),
                                row.get('cas_confirmes_fe', EMPTY_CELL),
                                row.get('total_cas', EMPTY_CELL),
                                row.get('per_cas_5', EMPTY_CELL),
                                row.get('per_cas_5_10', EMPTY_CELL),
                                row.get('per_cas_10', EMPTY_CELL),
                                row.get('per_cas_fa', EMPTY_CELL),
                                zone.name
                            ]