mitol-django-google-sheets-deferrals
This is the Open Learning Django Google Sheets library for handling deferral 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-deferrals
In settings.py
INSTALLED_APPS = [
...
"mitol.google_sheets_deferrals.apps.GoogleSheetsDeferralsApp",
]
MITOL_GOOGLE_SHEETS_DEFERRALS_PLUGINS = [
"ecommerce.plugins.DeferralPlugin"
]
In ecommerce/plugins.py
from mitol.google_sheets_deferrals.hooks import hookimpl
class DeferralPlugin:
@hookimpl
def deferrals_process_request(deferral_request: DeferralRequestRow) -> DeferralResult:
# TODO: look up the user/enrollment
# TODO: unenroll user from and enroll to
Create your google sheets folder
The structure of the folder should look as the following:
- Spreadsheet that contains sheets with 'Deferral Form Responses' and the 'Deferrals' 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_DEFERRALS_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_DEFERRALS_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_DEFERRALS_REQUEST_WORKSHEET_ID> -
MITOL_GOOGLE_SHEETS_DEFERRALS_PROCESSOR_COLThe zero-based index of the deferral change sheet column that contains the user that processed the row
-
MITOL_GOOGLE_SHEETS_DEFERRALS_COMPLETED_DATE_COLThe zero-based index of the deferral change sheet column that contains the row completion date
-
MITOL_GOOGLE_SHEETS_DEFERRALS_ERROR_COLThe zero-based index of the deferral change sheet column that contains row processing error messages
-
MITOL_GOOGLE_SHEETS_DEFERRALS_SKIP_ROW_COLThe zero-based index of the deferral change sheet column that indicates whether the row should be skipped
-
MITOL_GOOGLE_SHEETS_DEFERRALS_FIRST_ROWThe first row (as it appears in the spreadsheet) of data that our scripts should consider processing in the deferral request spreadsheet
Usage
To processing your google sheet with deferral requests simply add:
deferral_request_handler = DeferralRequestHandler()
results = deferral_request_handler.process_sheet()
Here are two main ways that we are currently getting our Google Sheets Deferrals processed:
- Run a management command. For example:
./manage.py process_deferral_requests -i "<spreadsheet id>" - Set up a scheduled celery task. For example:
from mitol.google_sheets_deferrals.api import DeferralRequestHandler
from main.celery import app
@app.task
def process_deferral_requests():
"""
Task to process deferral requests from Google sheets
"""
deferral_request_handler = DeferralRequestHandler()
if not deferral_request_handler.is_configured():
log.warning("MITOL_GOOGLE_SHEETS_* are not set")
return
deferral_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-deferrals 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_deferrals-2026.4.2.tar.gz | 7.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mitol_django_google_sheets_deferrals-2026.4.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.7 kB
Release files / mitol_django_google_sheets_deferrals-2026.4.2.tar.gz
| Download URL | mitol_django_google_sheets_deferrals-2026.4.2.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e2ae5539a4f86a33302bbac6be9efe857492ede1ee8aa0cb0e7caa01964f933
|
|
BLAKE2b-256 checksum How to use checksums |
28c1a043e81ab398053da28f47f322badd188b0c2a99f2ffce0387865a21db86
|
| 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_deferrals-2026.4.2-py3-none-any.whl
| Download URL | mitol_django_google_sheets_deferrals-2026.4.2-py3-none-any.whl |
|---|---|
| Size | 13.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2bf47ef33a4888d6d38acf48a2e1fa1c587a00a0e47c69cfd8d5bc6a112fdaa5
|
|
BLAKE2b-256 checksum How to use checksums |
c0f95ada1a0a24ca20ef5550ea356c06982b338f729eb072d33285f2ada9369d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|