Package: mitol-django-google-sheets-refunds
mitol-django-google-sheets-refundsThis is the Open Learning Django Google Sheets library for handling refund requests over Google SheetsSetupBefore you begin setting up this library make sure you set upmitol-django-google-sheetsfirst. Follow the instructionshere.Once you havemitol-django-google-sheetsinstalled, then:pip install mitol-django-google-sheets-refundsInsettings.pyINSTALLED_APPS=[..."mitol.google_sheets_refunds.apps.GoogleSheetsRefundsApp",]MITOL_GOOGLE_SHEETS_REFUNDS_PLUGINS=["ecommerce.plugins.RefundPlugin"]Inecommerce/plugins.pyfrommitol.google_sheets_refunds.hooksimporthookimplclassRefundPlugin:@hookimpldefrefunds_process_request(refund_request:RefundRequestRow)->RefundResult:# TODO: look up the user/order# TODO: mark the order as refunded# TODO: unenroll the userCreate your google sheets folderThe structure of the folder should look as the following:Spreadsheet that contains sheets with 'Refund Form Responses' and the 'Refunds' sheets, that is being processed.Request FormAsk a developer for a template folder to copy this structure.Add settings to your appSetMITOL_GOOGLE_SHEETS_REFUNDS_REQUEST_WORKSHEET_IDin your .env file. It is required.Some settings have default values, which you might need to update, if your sheet is different.Description of settings (in addition to the ones described inmitol-django-google-sheets):MITOL_GOOGLE_SHEETS_REFUNDS_REQUEST_WORKSHEET_IDThe IDs of the refund and deferral sheets in the change of enrollment spreadsheet. These can
be found by opening the spreadsheet, selecting the "Refunds" or "Deferrals" worksheets, and
copying down thegidvalue in the URL.Example:https://docs.google.com/spreadsheets/d/<MITOL_GOOGLE_SHEETS_ENROLLMENT_CHANGE_SHEET_ID>/edit#gid=<MITOL_GOOGLE_SHEETS_REFUNDS_REQUEST_WORKSHEET_ID>MITOL_GOOGLE_SHEETS_REFUNDS_PROCESSOR_COLThe zero-based index of the refund change sheet column that contains the user that processed the rowMITOL_GOOGLE_SHEETS_REFUNDS_COMPLETED_DATE_COLThe zero-based index of the refund change sheet column that contains the row completion dateMITOL_GOOGLE_SHEETS_REFUNDS_ERROR_COLThe zero-based index of the refund change sheet column that contains row processing error messagesMITOL_GOOGLE_SHEETS_REFUNDS_SKIP_ROW_COLThe zero-based index of the refund change sheet column that indicates whether the row should be skippedMITOL_GOOGLE_SHEETS_REFUNDS_FIRST_ROWThe first row (as it appears in the spreadsheet) of data that our scripts should consider processing in the refund request spreadsheetUsageTo processing your google sheet with refund requests simply add:refund_request_handler=RefundRequestHandler()results=refund_request_handler.process_sheet()Here are two main ways that we are currently getting our Google Sheets Refunds processed:Run a management command. For example:./manage.py process_refund_requests -i "<spreadsheet id>"Set up a scheduled celery task. For example:frommitol.google_sheets_refunds.apiimportRefundRequestHandlerfrommain.celeryimportapp@app.taskdefprocess_refund_requests():"""Task to process refund requests from Google sheets"""refund_request_handler=RefundRequestHandler()ifnotrefund_request_handler.is_configured():log.warning("MITOL_GOOGLE_SHEETS_* are not set")returnrefund_request_handler.process_sheet()Develper setupFor local development setup and testing please follow the instructionsDeveloper Setuphere.