Utils

app.enquiries.utils.csv_row_to_enquiry_filter_kwargs(csv_row: dict) dict

Converts a CSV row into a dict representing app.enquiries.models.Enquiry query kwargs e.g. enquiry__enquirer__first_name.

Parameters:

csv_row (dict) – The CSV row

Returns:

dict of queryset filter kwargs

app.enquiries.utils.generate_import_template(file_obj)

Generates an XLSX spreadsheet for use by by IST team to capture enquiries.

The main enquiry sheet is used by end users to capture information. The enquiry sheet columns are listed in app.enquiries.ref_data.IMPORT_COL_NAMES.

The additional sheets list valid options (i.e. Country names etc) which enable end users to implement their own form of validation.

The fields for these sheets are also listed in app.enquiries.ref_data

Parameters:

file_obj (file-like object) –

app.enquiries.utils.get_oauth_payload(request)

Extracts the user’s OAuth 2.0 token from session

Parameters:

request (django.http.HttpRequest) –

app.enquiries.utils.parse_error_messages(e)

Takes an error and parses its messages in human-readable form.

Where there are message dictionaries, separates out each message, parsing the keys into sentence case with title capitalisations

Parameters:

e (django.core.exceptions.ValidationError) –

Returns:

A list of error messages

app.enquiries.utils.row_to_enquiry(row: dict) Enquiry

Converts a CSV row into a persisted app.enquiries.models.Enquiry instance.

Parameters:

row (dict) –

Returns:

app.enquiries.models.Enquiry