Skip to content

feat: add Platform database model that defines the admin roles for each platform AAI-388#80

Merged
marius-mather merged 16 commits into
mainfrom
feature/platform-handling
Sep 26, 2025
Merged

feat: add Platform database model that defines the admin roles for each platform AAI-388#80
marius-mather merged 16 commits into
mainfrom
feature/platform-handling

Conversation

@marius-mather

@marius-mather marius-mather commented Sep 24, 2025

Copy link
Copy Markdown
Collaborator

Description

AAI-388: add a Platform model to the database. Add an endpoint to check which platforms the current user is an admin for (to be used by the frontend in guiding which views admins see).

Changes

  • Add Platform model to the database
  • Make PlatformMembership refer to Platform
  • Migrations for DB changes (including automatically creating the intial platforms)
  • /me/platforms/admin-roles endpoint that returns which platforms the admin is a user of.
  • /admin/users updated to only return users who are members of the admin's platforms
  • Unit tests added and updated

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • I have added unit / integration tests that prove my fix is effective or that my feature works
  • I have run all tests locally and they pass
  • I have updated the documentation (if applicable)

How to Test Manually (if necessary)

Run uv run pytest

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a Platform model to the database to define admin roles for each platform, enabling platform-specific admin access control. It updates the existing PlatformMembership model to reference the new Platform model and adds endpoints for admins to view which platforms they can manage.

  • Add Platform model with admin role associations
  • Update PlatformMembership to use foreign key relationship to Platform
  • Add endpoint for users to check their admin platforms

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
db/models.py Adds Platform model with admin roles relationship and updates PlatformMembership to reference Platform
routers/user.py Adds endpoint to get platforms where current user has admin privileges
routers/admin.py Updates user listing to filter by admin's platform access
migrations/ Database migrations to create Platform table and update constraints
tests/ Updates test files to use new Platform model and factory patterns
db/admin.py Adds Platform model to admin interface

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread db/models.py
Comment thread tests/test_admin.py Outdated
amandazhuyilan
amandazhuyilan previously approved these changes Sep 26, 2025

@amandazhuyilan amandazhuyilan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great :) just one more thing

Comment thread tests/db/test_models.py

@amandazhuyilan amandazhuyilan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the change!

@marius-mather marius-mather merged commit e721d0e into main Sep 26, 2025
2 of 3 checks passed
@amandazhuyilan amandazhuyilan deleted the feature/platform-handling branch June 19, 2026 03:22
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.

3 participants