Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,7 @@ class AccountMigrationRequest(BaseModel, table=True):
id: str = Field(default_factory=lambda: str(uuid.uuid7()), primary_key=True)
# Current user id: we want to maintain this as their primary ID after migration
user_id: str = Field(foreign_key="biocommons_user.id", index=True)
user: BiocommonsUser = Relationship(sa_relationship_kwargs={"foreign_keys": "AccountMigrationRequest.user_id"})
new_email: str = Field(nullable=False, max_length=254)
direction: MigrationDirection = Field(
sa_type=DbEnum(MigrationDirection, name="migration_direction_enum"),
Expand Down
15 changes: 15 additions & 0 deletions db/st_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from auth0.client import get_auth0_client
from config import get_settings
from db.models import (
AccountMigrationRequest,
Auth0Role,
BiocommonsGroup,
BiocommonsUser,
Expand Down Expand Up @@ -344,6 +345,19 @@ async def repr(self, obj: Any, request: Request) -> str:
return obj.subject


class AccountMigrationRequestView(DefaultView):
fields = [
HasOne("user", identity="user"),
"new_email",
"direction",
"status",
"created_at",
"expires_at",
]
fields_default_sort = [("created_at", True)]
searchable_fields = ["new_email"]


def setup_starlette_admin(app: FastAPI):
settings = get_settings()
if not settings.enable_admin_dashboard:
Expand All @@ -369,6 +383,7 @@ def setup_starlette_admin(app: FastAPI):
admin.add_view(GroupMembershipHistoryView(GroupMembershipHistory, identity="group_membership_history", icon="fa fa-clock-rotate-left"))
admin.add_view(EmailChangeOtpView(EmailChangeOtp, identity="email_change_otp", icon="fa fa-envelope"))
admin.add_view(EmailNotificationView(EmailNotification, identity="email_notification", icon="fa fa-envelope-open-text"))
admin.add_view(AccountMigrationRequestView(AccountMigrationRequest, identity="account_migration_request", icon="fa fa-arrow-right-arrow-left"))
admin.mount_to(app)


Expand Down
Loading