(request, domain)
return json_response({
        'success': True,
        'download_id': download.download_id,
    })
Uses the current exports download framework (with some nasty filters)
    to return the current download id to POLL for the download status.
    :return: {
        'success': True,
        'download_id': '<some uuid>',
    }
Uses the current exports download framework (with some nasty filters)
    to return the current download id to POLL for the download status.
    :return: {
        'success': True,
        'download_id': '<some uuid>',
    }
Uses the current exports download framework ( with some nasty filters ) to return the current download id to POLL for the download status . : return : { success : True download_id : <some uuid > }
def prepare_custom_export(request, domain):
    """Uses the current exports download framework (with some nasty filters)
    to return the current download id to POLL for the download status.
    :return: {
        'success': True,
        'download_id': '<some uuid>',
    }
    """
    form_or_case = request.POST.get('form_or_case')
    sms_export = json.loads(request.POST.get('sms_export'))
    permissions = ExportsPermissionsManager(form_or_case, domain, request.couch_user)
    permissions.access_download_export_or_404()

    view_helper = DownloadExportViewHelper.get(request, domain, form_or_case, sms_export)

    filter_form_data = json.loads(request.POST.get('form_data'))
    try:
        filter_form = view_helper.get_filter_form(filter_form_data)
    except ExportFormValidationException:
        return json_response({
            'error': _("Form did not validate."),
        })
    export_filters = filter_form.get_export_filters(request, filter_form_data)
    export_es_filters = [f.to_es_filter() for f in export_filters]

    export_specs = json.loads(request.POST.get('exports'))
    export_ids = [spec['export_id'] for spec in export_specs]
    export_instances = [view_helper.get_export(export_id) for export_id in export_ids]

    try:
        _check_deid_permissions(permissions, export_instances)
        _check_export_size(domain, export_instances, export_filters)
    except ExportAsyncException as e:
        return json_response({
            'error': str(e),
        })

    # Generate filename
    if len(export_instances) > 1:
        filename = "{}_custom_bulk_export_{}".format(domain, date.today().isoformat())
    else:
        filename = "{} {}".format(export_instances[0].name, date.today().isoformat())

    download = get_export_download(
        domain,
        export_ids,
        view_helper.model,
        request.couch_user.username,
        es_filters=export_es_filters,
        owner_id=request.couch_user.get_id,
        filename=filename,
    )

    view_helper.send_preparation_analytics(export_instances, export_filters)

    return json_response({
        'success': True,
        'download_id': download.download_id,
    })
def prepare_custom_export ( request , domain ) : form_or_case = request . POST . get ( 'form_or_case' ) sms_export = json . loads ( request . POST . get ( 'sms_export' ) ) permissions = ExportsPermissionsManager ( form_or_case , domain , request . couch_user ) permissions . access_download_export_or_404 ( ) view_helper = DownloadExportViewHelper . get ( request , domain , form_or_case , sms_export ) filter_form_data = json . loads ( request . POST . get ( 'form_data' ) ) try : filter_form = view_helper . get_filter_form ( filter_form_data ) except ExportFormValidationException : return json_response ( { 'error' : _ ( "Form did not validate." ) , } ) export_filters = filter_form . get_export_filters ( request , filter_form_data ) export_es_filters = [ f . to_es_filter ( ) for f in export_filters ] export_specs = json . loads ( request . POST . get ( 'exports' ) ) export_ids = [ spec [ 'export_id' ] for spec in export_specs ] export_instances = [ view_helper . get_export ( export_id ) for export_id in export_ids ] try : _check_deid_permissions ( permissions , export_instances ) _check_export_size ( domain , export_instances , export_filters ) except ExportAsyncException as e : return json_response ( { 'error' : str ( e ) , } ) # Generate filename if len ( export_instances ) > 1 : filename = "{}_custom_bulk_export_{}" . format ( domain , date . today ( ) . isoformat ( ) ) else : filename = "{} {}" . format ( export_instances [ 0 ] . name , date . today ( ) . isoformat ( ) ) download = get_export_download ( domain , export_ids , view_helper . model , request . couch_user . username , es_filters = export_es_filters , owner_id = request . couch_user . get_id , filename = filename , ) view_helper . send_preparation_analytics ( export_instances , export_filters ) return json_response ( { 'success' : True , 'download_id' : download . download_id , } )