Skip to content

Serve every bCourses course from one site, with seating's routes - #22

Merged
pancakereport merged 7 commits into
mainfrom
offerings
Nov 21, 2026
Merged

pancakereport merged 7 commits into
mainfrom
offerings

Conversation

@pancakereport

@pancakereport pancakereport commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

One oh-queue deployment now serves every bCourses course, as seating and sections do, with the same routes. This follows sections' #14.

Seating / Sections oh-queue (this PR)
Landing page, which redirects to /offerings when you're signed in / /
Your courses (staff, student, other) /offerings /offerings
Import staff courses from Canvas /offerings/new /offerings/new
A course /offerings/<canvas id>/… /offerings/<canvas id>/… (the queue and its API)
Login, OAuth callback, logout /login/, /authorized/, /logout/ same; replaces /oauth/canvas_login, /oauth/canvas_authorized, /oauth/logout

The landing, offerings, import and development-login pages reuse sections' templates and its vendored Bootstrap 5 (oh_queue/templates/pages, oh_queue/static/pages). The queue itself looks the same.

Data model. The migration only adds tables; no existing rows change.

  • New offerings table (Offering, as in seating and sections). It maps a bCourses course to the key stored in every row's course column.
    • Imported courses use their bCourses ID as the key.
    • Courses from the per-course sites keep their old key (cs61a, …) and are linked with python manage.py link-offering <canvas id> <key> "<name>". A linked course gets its Canvas name, code and start date the first time a member opens /offerings.
  • New account table: the signed-in person and their role in every bCourses course, fetched in one call at sign-in.
    • Inside a course, the account is matched by email to that course's existing user row, which is created on the first visit. Its staff status follows the account's roles.
    • user rows stay per course, because call links, heartbeat and staff status are per course here.

Other changes

  • Course admins (instructors and Lead TAs) can hide an offering. Hiding marks the row hidden rather than deleting it, so importing the course again brings it back under the same key with its data, including a course linked to an old key like cs61a. (Sections deletes the row, which strands a linked course's data: Hiding a linked offering strands its data sections#101.)
  • If an open queue page's API calls are refused (no longer enrolled) or the course is hidden, the page reloads to show why, instead of seeming offline.
  • Only people enrolled in a course on bCourses, as staff or students, can open its queue; others get a 403, as in sections. Members of the admin override course are staff everywhere. The admin setting "Should only students on the roster be allowed to log in?" (never enforced in this repo) is removed, and the migration deletes it from every course.
  • Signed-out visitors see how long a course's queue is (tab counts and the wait estimate) but no tickets: the server sends them a count per status instead of the tickets, which used to include each one's question, assignment, location, times and helper.
  • Errors (not enrolled, a hidden or unknown course) show the site's error page, as in sections, with the reason and a button back to the site; course API errors are JSON with the message.
  • Logging out is a POST, so other sites can't sign people out.
  • Cookies from the per-course sites are ignored, so an old per-course user ID can't be read as an account.
  • Sign-in asks bCourses for fewer permissions: just the user, their profile and their courses.
  • The React app gets the course's path as its router basename and API prefix. Server redirects are paths within the course.
  • Removed /debug, which only worked with a single course and returned an empty page.
  • COURSE_KEY and CANVAS_COURSE_ID are no longer used.

Not changed here: sign-ins are still remembered with the roles from the last sign-in. Sections now expires them after 12 hours; that belongs with the security work in #2.

Before deploying

  • Add /authorized/ to the Canvas developer key's redirect URIs; the callback moved from /oauth/canvas_authorized
  • Remove COURSE_KEY and CANVAS_COURSE_ID from the deployment's settings
  • After prod data is copied to Postgres, link each old course: python manage.py link-offering <bCourses id> <key> "<name>"

Test plan

  • 102 tests pass, flake8 is clean. New tests cover:
    • the offering pages: landing, sign-in redirects, staff/student/other lists, importing (staff only), hiding (course admins only) and importing again, which brings back a linked course's key and data
    • linked offerings getting their Canvas details
    • IDs too big for the offerings column
    • courses kept apart: tickets, users and roles in one course don't reach another, including through another course's API
    • signed-out visitors getting counts, not tickets
    • roles following Canvas, admin override, enrollment being required, and ignored old cookies
    • link-offering, and the migration both ways
  • Migration run down and up on Postgres 18 (including the hidden default), and on SQLite
  • Clicked through locally with seed data: the course queue, a ticket page (opened by link and by URL), assigning it, Admin, the offerings page, and signing in and out. No console errors. Signed out, the queue shows only the counts and the wait estimate.
  • Full click-through on a fresh database with three courses: signed out; a student asking for help, describing, chatting, ticket history, a party group; staff helping, chatting, resolving, Next Ticket, every Admin tab, adding an assignment, online setup, activity log, presence; importing a course; a course hidden while open (page reloads to the 404), then imported again with its key and data; a student dropped from a course while on its page (reloads to the 403)
  • On a deployment: sign in with bCourses, import a course, open a linked course and see its existing data

🤖 Generated with Claude Code

One deployment now serves every course, as seating and sections do: a
landing page at /, your courses at /offerings, importing a course at
/offerings/new, and each course's queue and API at
/offerings/<bCourses course id>/. Sign-in moves to /login/,
/authorized/ and /logout/.

New offerings table maps a bCourses course to the key on every row;
courses from the per-course sites are linked to their old key with
`flask link-offering`. New account table holds the signed-in person and
their roles in every bCourses course, fetched once at sign-in; inside a
course it resolves to that course's existing user row, made on first
visit. No existing rows change.

The admin setting that only lets students on the roster in is now
enforced, logout is a POST, and COURSE_KEY and CANVAS_COURSE_ID are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov-commenter

codecov-commenter commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.58703% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.66%. Comparing base (885128d) to head (724e818).

Files with missing lines Patch % Lines
oh_queue/offerings.py 92.63% 4 Missing and 3 partials ⚠️
oh_queue/login.py 98.46% 1 Missing ⚠️
oh_queue/models.py 98.14% 1 Missing ⚠️
oh_queue/offering.py 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #22      +/-   ##
==========================================
+ Coverage   67.76%   72.66%   +4.90%     
==========================================
  Files           8       10       +2     
  Lines        1185     1394     +209     
  Branches      173      198      +25     
==========================================
+ Hits          803     1013     +210     
+ Misses        324      323       -1     
  Partials       58       58              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

pancakereport and others added 4 commits November 20, 2026 14:01
…etting

A course's queue is now only open to its bCourses staff and students (and
members of the admin override course), as in sections, so the
only_registered_students setting isn't needed. The migration removes it
from every course and puts it back, off, on downgrade.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Refuse a sign-in clearly when the bCourses profile has no email,
  instead of failing to save the account.
- Show a message, not an error, when someone else imports the same
  course at the same time.
- Save and sign in accounts in one helper, shared by bCourses sign-in
  and the development login.
- Look up an offering by Canvas ID in one place, which skips IDs too big
  for the column.
- Remove a template branch copied from sections for a page oh-queue
  doesn't have.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-out visitors used to get every active ticket as the queue lists
it: question, assignment, location, times and helper. Now they get no
tickets, only how many have each status, which the page uses for the tab
counts and the wait estimate, with a prompt to sign in to see the queue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pancakereport and others added 2 commits November 20, 2026 16:13
- Hiding an offering marks it hidden instead of deleting its row, so
  importing the course again brings it back under the same key. Before,
  a course linked to an old key (like cs61a) came back empty, its data
  still under the old key.
- When the course API refuses an open page (no longer enrolled) or the
  course is gone (hidden), reload the page if it fails too, so it shows
  why instead of seeming offline.
- Build course paths with url_for, and share the term month and
  newest-first order between the offerings and import pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
People not enrolled in a course, or opening a hidden or unknown one, got
Werkzeug's bare error page, which told them to log out but had no way to
(logging out is a POST). Errors now use the site's page, as in sections:
the reason and a button back to the site, where the navbar can log out.
Course API errors are JSON with the message.

Also make the README's link-offering command match its other commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pancakereport
pancakereport merged commit 27aafc2 into main Nov 21, 2026
9 checks passed
@pancakereport
pancakereport deleted the offerings branch November 21, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants