Beispiel #1
0
    def _to_case_export_instance_filters(self, can_access_all_locations,
                                         accessible_location_ids):
        emwf_selections = self.cleaned_data["emwf_case_filter"]

        return CaseExportInstanceFilters(
            date_period=DatePeriod(
                period_type=self.cleaned_data['date_range'],
                days=self.cleaned_data['days'],
                begin=self.cleaned_data['start_date'],
                end=self.cleaned_data['end_date'],
            ),
            users=CaseListFilter.selected_user_ids(emwf_selections),
            reporting_groups=CaseListFilter.selected_reporting_group_ids(
                emwf_selections),
            locations=CaseListFilter.selected_location_ids(emwf_selections),
            user_types=CaseListFilter.selected_user_types(emwf_selections),
            can_access_all_locations=can_access_all_locations,
            accessible_location_ids=accessible_location_ids,
            sharing_groups=CaseListFilter.selected_sharing_group_ids(
                emwf_selections),
            show_all_data=CaseListFilter.show_all_data(emwf_selections)
            or CaseListFilter.no_filters_selected(emwf_selections),
            show_project_data=CaseListFilter.show_project_data(
                emwf_selections),
        )
Beispiel #2
0
    def _to_form_export_instance_filters(self, can_access_all_locations, accessible_location_ids):
        emwf_selections = self.cleaned_data["emwf_form_filter"]

        return FormExportInstanceFilters(
            date_period=DatePeriod(
                period_type=self.cleaned_data['date_range'],
                days=self.cleaned_data['days'],
                begin=self.cleaned_data['start_date'],
                end=self.cleaned_data['end_date'],
            ),
            users=ExpandedMobileWorkerFilter.selected_user_ids(emwf_selections),
            reporting_groups=ExpandedMobileWorkerFilter.selected_reporting_group_ids(emwf_selections),
            locations=ExpandedMobileWorkerFilter.selected_location_ids(emwf_selections),
            user_types=ExpandedMobileWorkerFilter.selected_user_types(emwf_selections),
            can_access_all_locations=can_access_all_locations,
            accessible_location_ids=accessible_location_ids,
        )
Beispiel #3
0
    def create_new_export_instance(self, schema):
        instance = super(DailySavedExportMixin, self).create_new_export_instance(schema)
        instance.is_daily_saved_export = True

        span = datespan_from_beginning(self.domain_object, get_timezone(self.domain, self.request.couch_user))
        instance.filters.date_period = DatePeriod(
            period_type="since", begin=span.startdate.date()
        )
        if not self.request.can_access_all_locations:
            accessible_location_ids = (SQLLocation.active_objects.accessible_location_ids(
                self.request.domain,
                self.request.couch_user)
            )
        else:
            accessible_location_ids = None
        instance.filters.can_access_all_locations = self.request.can_access_all_locations
        instance.filters.accessible_location_ids = accessible_location_ids

        return instance