#NEWLINE# def create_export_filter( request , domain , export_type = 'form' ) : #NEWLINE# #INDENT# request_obj = ( request . POST if ( request . method == 'POST' ) else request . GET ) #NEWLINE# from corehq.apps.reports.filters.users import UserTypeFilter #NEWLINE# app_id = request_obj . get ( 'app_id' , None ) #NEWLINE# ( user_filters , use_user_filters ) = UserTypeFilter . get_user_filter ( request ) #NEWLINE# use_user_filters &= bool ( user_filters ) #NEWLINE# group = ( None if use_user_filters else get_group ( ** json_request ( request_obj ) ) ) #NEWLINE# if ( export_type == 'case' ) : #NEWLINE# #INDENT# if use_user_filters : #NEWLINE# #INDENT# groups = [ g . get_id for g in Group . get_case_sharing_groups ( domain ) ] #NEWLINE# filtered_users = users_matching_filter ( domain , user_filters ) #NEWLINE# filter = SerializableFunction ( case_users_filter , users = filtered_users , groups = groups ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# filter = SerializableFunction ( case_group_filter , group = domain ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# filter = SerializableFunction ( app_export_filter , app_id = app_id ) #NEWLINE# datespan = request . datespan #NEWLINE# if datespan . is_valid ( ) : #NEWLINE# #INDENT# datespan . set_timezone ( get_timezone_for_user ( request . couch_user , domain ) ) #NEWLINE# filter &= SerializableFunction ( datespan_export_filter , datespan = datespan ) #NEWLINE# #UNINDENT# if use_user_filters : #NEWLINE# #INDENT# filtered_users = users_matching_filter ( domain , user_filters ) #NEWLINE# filter &= SerializableFunction ( users_filter , users = filtered_users ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# filter &= SerializableFunction ( group_filter , group = group ) #NEWLINE# #UNINDENT# #UNINDENT# return filter