-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add Platform database model that defines the admin roles for each platform AAI-388 #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4ee0e8c
Add a Platform model where we can define the admin roles for each pla…
marius-mather 181bd36
Don't automatically set relationships in datagen models - doesn't wor…
marius-mather 4b551f5
Make sure we set group/user ID when saving history
marius-mather b71d4df
Fix tests of GroupMembership
marius-mather 0ffb735
Add factory for creating platforms
marius-mather 062f353
Update test of platform membership creation to test platform is assoc…
marius-mather b610934
Test platform creation
marius-mather f9264f3
Test platform IDs are unique
marius-mather 7873f40
Test getting admin platforms
marius-mather 58fda69
Add migrations for updated models
marius-mather f323d63
Add PlatformAdmin to backend DB admin
marius-mather 00e8115
Update get_users endpoint to only return users for platforms the admi…
marius-mather 6730fd6
Update tests of get_users to include platform-specific users
marius-mather 338a1d7
Style fix
marius-mather 7a99581
Fix creating platform in test
marius-mather 9f2df65
Comment on checking platform membership creation
marius-mather File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| """platform_constraints | ||
|
|
||
| Revision ID: 08a3d0593418 | ||
| Revises: 575a146957f2 | ||
| Create Date: 2025-09-24 10:38:24.506817 | ||
|
|
||
| """ | ||
| from typing import Sequence, Union | ||
|
|
||
| from alembic import op | ||
| import sqlalchemy as sa | ||
| import sqlmodel | ||
|
|
||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision: str = '08a3d0593418' | ||
| down_revision: Union[str, None] = '575a146957f2' | ||
| branch_labels: Union[str, Sequence[str], None] = None | ||
| depends_on: Union[str, Sequence[str], None] = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.create_unique_constraint(op.f('uq_platform_id'), 'platform', ['id']) | ||
| # ### end Alembic commands ### | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.drop_constraint(op.f('uq_platform_id'), 'platform', type_='unique') | ||
| # ### end Alembic commands ### |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| """platform_model | ||
|
|
||
| Revision ID: 575a146957f2 | ||
| Revises: 1546c07b9d78 | ||
| Create Date: 2025-09-24 10:07:01.958231 | ||
|
|
||
| """ | ||
| from typing import Sequence, Union | ||
|
|
||
| from alembic import op | ||
| import sqlalchemy as sa | ||
| import sqlmodel | ||
|
|
||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision: str = '575a146957f2' | ||
| down_revision: Union[str, None] = '1546c07b9d78' | ||
| branch_labels: Union[str, Sequence[str], None] = None | ||
| depends_on: Union[str, Sequence[str], None] = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| # NOTE: alembic doesn't automatically add new enum values to existing types | ||
| op.execute('ALTER TYPE "PlatformEnum" ADD VALUE \'SBP\'') | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.create_table('platform', | ||
| sa.Column('id', sa.Enum('GALAXY', 'BPA_DATA_PORTAL', 'SBP', name='PlatformEnum'), nullable=False), | ||
| sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False), | ||
| sa.PrimaryKeyConstraint('id', name=op.f('pk_platform')), | ||
| sa.UniqueConstraint('id', name=op.f('uq_platform_id')), | ||
| sa.UniqueConstraint('name', name=op.f('uq_platform_name')) | ||
| ) | ||
|
|
||
| # Insert the platform records that might be referenced by existing platformmembership records | ||
| op.execute("INSERT INTO platform (id, name) VALUES ('GALAXY', 'Galaxy Australia')") | ||
| op.execute("INSERT INTO platform (id, name) VALUES ('BPA_DATA_PORTAL', 'Bioplatforms Australia Data Portal')") | ||
| op.execute("INSERT INTO platform (id, name) VALUES ('SBP', 'Structural Biology Platform')") | ||
|
|
||
| op.create_table('platformrolelink', | ||
| sa.Column('platform_id', sa.Enum('GALAXY', 'BPA_DATA_PORTAL', 'SBP', name='PlatformEnum'), nullable=False), | ||
| sa.Column('role_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False), | ||
| sa.ForeignKeyConstraint(['platform_id'], ['platform.id'], name=op.f('fk_platformrolelink_platform_id_platform')), | ||
| sa.ForeignKeyConstraint(['role_id'], ['auth0role.id'], name=op.f('fk_platformrolelink_role_id_auth0role')), | ||
| sa.PrimaryKeyConstraint('platform_id', 'role_id', name=op.f('pk_platformrolelink')) | ||
| ) | ||
| # Create foreign key constraint for platformmembership.platform_id | ||
| op.create_foreign_key(op.f('fk_platformmembership_platform_id_platform'), 'platformmembership', 'platform', ['platform_id'], ['id']) | ||
| # ### end Alembic commands ### | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.drop_constraint(op.f('fk_platformmembership_platform_id_platform'), 'platformmembership', type_='foreignkey') | ||
| op.drop_table('platformrolelink') | ||
| op.drop_table('platform') | ||
| # ### end Alembic commands ### |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.