(request, domain)
return render(request, "case_importer/excel_fields.html", context)
Step two of three.

    Important values that are grabbed from the POST or defined by
    the user on this page:

    case_type:
        The type of case we are matching to. When creating new cases,
        this is the type they will be created as. When updating
        existing cases, this is the type that we will search for.
        If the wrong case type is used when looking up existing cases,
        we will not update them.

    create_new_cases:
        A boolean that controls whether or not the user wanted
        to create new cases for any case that doesn't have a matching
        case id in the upload.

    search_column:
        Which column of the Excel file we are using to specify either
        case ids or external ids. This is, strangely, required. If
        creating new cases only you would expect these to be blank with
        the create_new_cases flag set.

    search_field:
        Either case id or external id, determines which type of
        identification we are using to match to cases.
Step two of three.
Step two of three .
def excel_fields(request, domain):
    """
    Step two of three.

    Important values that are grabbed from the POST or defined by
    the user on this page:

    case_type:
        The type of case we are matching to. When creating new cases,
        this is the type they will be created as. When updating
        existing cases, this is the type that we will search for.
        If the wrong case type is used when looking up existing cases,
        we will not update them.

    create_new_cases:
        A boolean that controls whether or not the user wanted
        to create new cases for any case that doesn't have a matching
        case id in the upload.

    search_column:
        Which column of the Excel file we are using to specify either
        case ids or external ids. This is, strangely, required. If
        creating new cases only you would expect these to be blank with
        the create_new_cases flag set.

    search_field:
        Either case id or external id, determines which type of
        identification we are using to match to cases.

    """
    case_type = request.POST['case_type']
    try:
        search_column = request.POST['search_column']
    except MultiValueDictKeyError:
        # this is only true if your configuration is messed up in an irreparable way
        messages.error(request, _('The Excel file you are trying to import does not have any headers.'))
        return HttpResponseRedirect(base.ImportCases.get_url(domain))

    search_field = request.POST['search_field']
    create_new_cases = request.POST.get('create_new_cases') == 'on'

    case_upload = CaseUpload.get(request.session.get(EXCEL_SESSION_ID))

    try:
        case_upload.check_file()
    except ImporterError as e:
        return render_error(request, domain, get_importer_error_message(e))

    with case_upload.get_spreadsheet() as spreadsheet:
        columns = spreadsheet.get_header_columns()
        excel_fields = columns

    # hide search column and matching case fields from the update list
    if search_column in excel_fields:
        excel_fields.remove(search_column)

    # 'domain' case property cannot be created if domain mirror flag is enabled,
    # as this enables a multi-domain case import.
    # see: https://dimagi-dev.atlassian.net/browse/USH-81
    if 'domain' in excel_fields and DOMAIN_PERMISSIONS_MIRROR.enabled(domain):
        excel_fields.remove('domain')
        mirroring_enabled = True
    else:
        mirroring_enabled = False

    field_specs = get_suggested_case_fields(
        domain, case_type, exclude=[search_field])

    case_field_specs = [field_spec.to_json() for field_spec in field_specs]

    context = {
        'case_type': case_type,
        'search_column': search_column,
        'search_field': search_field,
        'create_new_cases': create_new_cases,
        'columns': columns,
        'excel_fields': excel_fields,
        'case_field_specs': case_field_specs,
        'domain': domain,
        'mirroring_enabled': mirroring_enabled,
    }
    context.update(_case_importer_breadcrumb_context(_('Match Excel Columns to Case Properties'), domain))
    return render(request, "case_importer/excel_fields.html", context)
def excel_fields ( request , domain ) : case_type = request . POST [ 'case_type' ] try : search_column = request . POST [ 'search_column' ] except MultiValueDictKeyError : # this is only true if your configuration is messed up in an irreparable way messages . error ( request , _ ( 'The Excel file you are trying to import does not have any headers.' ) ) return HttpResponseRedirect ( base . ImportCases . get_url ( domain ) ) search_field = request . POST [ 'search_field' ] create_new_cases = request . POST . get ( 'create_new_cases' ) == 'on' case_upload = CaseUpload . get ( request . session . get ( EXCEL_SESSION_ID ) ) try : case_upload . check_file ( ) except ImporterError as e : return render_error ( request , domain , get_importer_error_message ( e ) ) with case_upload . get_spreadsheet ( ) as spreadsheet : columns = spreadsheet . get_header_columns ( ) excel_fields = columns # hide search column and matching case fields from the update list if search_column in excel_fields : excel_fields . remove ( search_column ) # 'domain' case property cannot be created if domain mirror flag is enabled, # as this enables a multi-domain case import. # see: https://dimagi-dev.atlassian.net/browse/USH-81 if 'domain' in excel_fields and DOMAIN_PERMISSIONS_MIRROR . enabled ( domain ) : excel_fields . remove ( 'domain' ) mirroring_enabled = True else : mirroring_enabled = False field_specs = get_suggested_case_fields ( domain , case_type , exclude = [ search_field ] ) case_field_specs = [ field_spec . to_json ( ) for field_spec in field_specs ] context = { 'case_type' : case_type , 'search_column' : search_column , 'search_field' : search_field , 'create_new_cases' : create_new_cases , 'columns' : columns , 'excel_fields' : excel_fields , 'case_field_specs' : case_field_specs , 'domain' : domain , 'mirroring_enabled' : mirroring_enabled , } context . update ( _case_importer_breadcrumb_context ( _ ( 'Match Excel Columns to Case Properties' ) , domain ) ) return render ( request , "case_importer/excel_fields.html" , context )