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, )
def _to_form_export_instance_filters(self, can_access_all_locations, accessible_location_ids): emwf_selections = [x['id'] for x in 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, )
def _extract_location_id(location_id_slug): from corehq.apps.reports.filters.users import ExpandedMobileWorkerFilter selected_ids = ExpandedMobileWorkerFilter.selected_location_ids( [location_id_slug]) return selected_ids[0] if selected_ids else None