Record a summer registration as a registration of its own - #1971
Merged
vikrantwiz02 merged 1 commit intoAug 27, 2026
Merged
Conversation
course_registration was unique on (course, student, semester, registration_type). A summer term has no semester row of its own -- it anchors to the adjacent one -- so a summer registration of a course the student already held that semester produced the same key as the regular one, and bulk_create(ignore_conflicts=True) discarded it without a word. The upload then reported success because it counted the list it had built rather than the rows the table accepted, so a whole batch could be allotted a summer course and nothing would be written. The term now forms part of the key, so the two registrations coexist. Alongside that, allot_courses counts what the table took, reports how many rows were already registered, and names the roll number, course, slot and term in each row failure instead of leaving a bare lookup error. A repeat within one term takes its type from the grade on record, and a missing academic year is answered with a 400 rather than raising.
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.
A bulk course allotment for a summer term reported
Successfully uploaded! inserted_rows: 61while writing nothing at all. The summer registrations were being discarded silently.Cause.
course_registrationwas unique on(course_id, student_id, semester_id, registration_type). A summer term has noSemesterrow of its own — it anchors to the adjacent regular semester — so a summer registration of a course the student already held in that semester produced an identical key to the regular one, andbulk_create(ignore_conflicts=True)dropped it. The view then reportedlen(course_regs)as the number inserted, so the failure was invisible: the office saw success, and the student's courses still showed only the regular term.Fix.
semester_typejoins the uniqueness key (migration0052_course_registration_term_unique), so the two registrations are distinct rows on every code path, not just this endpoint. Adding a column to a unique key only relaxes it, so no existing row can conflict; there are no rows with a null term.Alongside it, in
allot_courses:Course matching query does not exist.parse_academic_year, which was called before the required-field checkVerified against a restored copy of the live database, inside rolled-back transactions: a batch upload for a summer term writes one summer row per student beside the existing regular row, re-running the same upload adds nothing and reports every row as already registered, and the student-courses endpoint returns both registrations with their own terms.
manage.py checkclean, no further migrations detected.