Library to handle Refund requests using Google Sheets integrations in Django
Project description
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_ID
The 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
gid
value 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_COL
The zero-based index of the refund change sheet column that contains the user that processed the row
-
MITOL_GOOGLE_SHEETS_REFUNDS_COMPLETED_DATE_COL
The zero-based index of the refund change sheet column that contains the row completion date
-
MITOL_GOOGLE_SHEETS_REFUNDS_ERROR_COL
The zero-based index of the refund change sheet column that contains row processing error messages
-
MITOL_GOOGLE_SHEETS_REFUNDS_SKIP_ROW_COL
The zero-based index of the refund change sheet column that indicates whether the row should be skipped
-
MITOL_GOOGLE_SHEETS_REFUNDS_FIRST_ROW
The 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mitol-django-google-sheets-refunds-2023.12.19.tar.gz
.
File metadata
- Download URL: mitol-django-google-sheets-refunds-2023.12.19.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c62fd7a6076130cfb1b436345133e9a909b678b1706f048512097280a911d90a |
|
MD5 | 8910607769cee20967f08f5b366f810e |
|
BLAKE2b-256 | 883277c1620069056793eca184e58ba34da41d35e1851f42686ae6c447a3da6d |
File details
Details for the file mitol_django_google_sheets_refunds-2023.12.19-py3-none-any.whl
.
File metadata
- Download URL: mitol_django_google_sheets_refunds-2023.12.19-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97e04903a0f2dbb722905c3ba5a9efb92197d7c041783b471fad11ee2a6ebfe0 |
|
MD5 | bf1ad6460c201c50c1a0753bce95c334 |
|
BLAKE2b-256 | 2daa20f10d7872aa59771c43eacb702f0f362abbb4af5c123737d1b92b41acdb |