Add courses in bulk from a spreadsheet - #1981
Merged
vikrantwiz02 merged 1 commit intoSep 3, 2026
Merged
Conversation
Setting up a session meant adding courses one at a time through the proposal form. This takes a file instead: one row per course, reading .xlsx, .xls or .csv, since a file named .xlsx is often really an .xls. Course code, name, credits, max seats and disciplines are required. The rest are optional and fall back to the model defaults, which is what keeps the seven assessment percentages adding up to 100 without the office carrying seven more columns. A course shared across disciplines lists them in one cell separated by semicolons, commas or pipes, matched without regard to case or punctuation so Des., Des and des all resolve. Each row commits in its own savepoint, so one bad row cannot take down the batch, and the count reported is what the table accepted rather than the length of the list. Every failure names the row and what is wrong with it. Courses created this way get the same audit log entry as one added through the form.
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.
Setting up a session meant adding courses one at a time through the proposal form.
POST /programme_curriculum/api/admin_add_courses_bulk/takes a file instead — one row per course — gated toacadadminandDean Academiclike the single-add view, and writing the same audit log entry per course.Reads .xlsx, .xls and .csv. All three deliberately: a file named
.xlsxis frequently a legacy.xls, whichxlrdalone rejects.The seven assessment percentages are deliberately not columns.
CourseFormrequires them to total exactly 100 and the model defaults already do, so the sheet stays short and the invariant holds by construction. The bulk path therefore builds the model directly with explicit per-field validation instead of going through the form, and each check reports its own message.A course shared across disciplines lists them in one cell. Semicolons and pipes are accepted besides commas, because a comma inside a cell has to be quoted in a CSV and that is easy to get wrong by hand; matching ignores case and punctuation, since one acronym in the table is
Des.with a trailing dot.Verified against a restored copy of the live database, inside rolled-back transactions.
Formats and failures:
Disciplines, every spelling:
A row naming one unknown discipline is rejected whole rather than saved with a partial set, and the unknown name is echoed back as typed. Each row commits in its own savepoint, so one bad row cannot take down the batch, and the counts come from the table rather than the length of the list.
manage.py checkclean, no migration. Pairs with the client PR adding the Bulk Add button.