Donne120 Claude Sonnet 5 commited on
Commit
ff2925e
·
1 Parent(s): bebdbb7

feat(admin): let a platform admin change a university's plan tier

Browse files

Confirmed there was genuinely no way to do this — plan_tier has existed
as a column since the original schema (CHECK constraint restricts it to
free/pro/enterprise, default 'free', confirmed live) but nothing ever
wrote to it after row creation, and no endpoint returned it consistently.

- New PATCH /admin/organizations/{org_id}/plan, platform-admin only (a
school's own admin — who CAN manage their own org's admin list, per the
earlier organization_admins work — must not be able to self-upgrade
their own plan).
- plan_tier added to every organization SELECT/RETURNING clause
(list/create/deactivate/get-my-org) — it was silently missing from all
four, the same "field quietly never sent to the frontend" bug already
hit twice today with created_at.

8 tests cover: changing the plan, rejecting an invalid tier before
touching the database (matches the real CHECK constraint's three values),
unknown org 404, platform-admin-only access, and all three real tiers
accepted. Full suite (80 tests) passes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

2 files changed +209 -4
Files changed (2)
admin_routes.py+47-4
test_organization_plan.pyAdded+162