Add send-to-Google-Sheets support for B2B enrollment codes#3363
Draft
Add send-to-Google-Sheets support for B2B enrollment codes#3363
Conversation
OpenAPI ChangesShow/hide ## Changes for v0.yaml:Unexpected changes? Ensure your branch is up-to-date with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What are the relevant tickets?
Closes mitodl/hq#7931
Description (What does it do?)
Adds the ability to send a contract's enrollment codes to a Google Sheet.
This PR adds a couple of new fields to the
ContractPagemodel. These fields allow the user to specify the URL to a Google Sheet that we can throw codes into, and what worksheet (tab) within the document to use for this purpose. When set, the system will write enrollment codes to the sheet, and update the status of the individual codes as they're used.Each
ContractPagecan have its own individual Google Sheet to work in. Or, it can share a Sheet with other contracts and use a specified tab within the sheet. For now, only one mapping is supported per contract. To make things easier for folks managing the contract, the integration takes a URL to the sheet rather than a bare sheet ID. The sheet must be writable by MITx Online's configured service account.How can this be tested?
You'll need the Google Sheets integration set up. Should be some docs for this alongside the deferrals/refunds code. The enrollment codes code uses the same underlying setup.
Create a new Google Sheet with nothing in it. Make sure it's created in a way that it should be visible and writable by the user you're using for MITx Online. Then, create a contract that involves codes, and paste in the sheet's URL where it says. (Test specifying the individual tab as well.)
b2b_codescommand. This should mark the code as invalid in the sheet but leave the code there.Additional Context
The integration uses the same base stuff that the deferrals and refunds processing code uses, but works a good bit differently. The refund/deferral code expects to only ever read a single sheet and this expects to work on any number of sheets. So, it's using the ol-django
google_sheetscode but really only to bootstrap pygsheets.The code will check for and write a header row to whatever worksheet is configured so it's best to give it a blank sheet to work from. The header row will be written the first N columns don't match the columns set in the code.
A field was also added to the
Discountmodel to keep track of where the code lands in the sheet, so it doesn't have to trawl through the entire sheet to update a code. (There can be potentially thousands of codes.) It will check to make sure the code is actually there; if it isn't, then it'll default to iterating through the sheet to find it.There's options in here to set the start row but we're not using the at the moment.