mitol-django-google-sheets-refunds
This is the Open Learning Django Google Sheets library for handling refund requests over Google Sheets
Setup
Before you begin setting up this library make sure you set up mitol-django-google-sheets first. Follow the instructions here.
Once you have mitol-django-google-sheets installed, then:
pip install mitol-django-google-sheets-refunds
In settings.py
INSTALLED_APPS = [
...
"mitol.google_sheets_refunds.apps.GoogleSheetsRefundsApp",
]
MITOL_GOOGLE_SHEETS_REFUNDS_PLUGINS = [
"ecommerce.plugins.RefundPlugin"
]
In ecommerce/plugins.py
from mitol.google_sheets_refunds.hooks import hookimpl
class RefundPlugin:
@hookimpl
def refunds_process_request(refund_request: RefundRequestRow) -> RefundResult:
# TODO: look up the user/order
# TODO: mark the order as refunded
# TODO: unenroll the user
Create your google sheets folder
The 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 Form
Ask a developer for a template folder to copy this structure.
Add settings to your app
Set MITOL_GOOGLE_SHEETS_REFUNDS_REQUEST_WORKSHEET_ID in 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 in mitol-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 the
gidvalue 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 row
-
MITOL_GOOGLE_SHEETS_REFUNDS_COMPLETED_DATE_COLThe zero-based index of the refund change sheet column that contains the row completion date
-
MITOL_GOOGLE_SHEETS_REFUNDS_ERROR_COLThe zero-based index of the refund change sheet column that contains row processing error messages
-
MITOL_GOOGLE_SHEETS_REFUNDS_SKIP_ROW_COLThe zero-based index of the refund change sheet column that indicates whether the row should be skipped
-
MITOL_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 spreadsheet
Usage
To 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:
from mitol.google_sheets_refunds.api import RefundRequestHandler
from main.celery import app
@app.task
def process_refund_requests():
"""
Task to process refund requests from Google sheets
"""
refund_request_handler = RefundRequestHandler()
if not refund_request_handler.is_configured():
log.warning("MITOL_GOOGLE_SHEETS_* are not set")
return
refund_request_handler.process_sheet()
Develper setup
For local development setup and testing please follow the instructions Developer Setup here.
Metadata
Release files for mitol-django-google-sheets-refunds 2026.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mitol_django_google_sheets_refunds-2026.4.2.tar.gz | 8.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mitol_django_google_sheets_refunds-2026.4.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.7 kB
Release files / mitol_django_google_sheets_refunds-2026.4.2.tar.gz
| Download URL | mitol_django_google_sheets_refunds-2026.4.2.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd88f30a132f30bc4f8405434dea0f2b61d0e0b27dd33abf4a5e3b6a4e879aeb
|
|
BLAKE2b-256 checksum How to use checksums |
cc779f62860609868bd2caf8be25471df94b368adee83f896e67d252c7bc9455
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / mitol_django_google_sheets_refunds-2026.4.2-py3-none-any.whl
| Download URL | mitol_django_google_sheets_refunds-2026.4.2-py3-none-any.whl |
|---|---|
| Size | 14.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
90b2548150ddb9ed5275771a720f89ca17b85c32137f5f153808662397beb4a2
|
|
BLAKE2b-256 checksum How to use checksums |
ec5c877a00ff7f344ddc553f9ece75c497ea91c17cd7f8b55221ff1adafc99ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|