Extract shared player ownership verification utility #54
Labels
No Label
ai-changes-requested
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
in-next-release
status/in-progress
status/pr-open
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/major-domo-v2#54
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Both
InjuryGroup._verify_team_ownership(commands/injuries/management.py) andcan_edit_player_image(commands/profile/images.py) implement nearly identical logic to check whether the invoking user owns the organization a player belongs to.They should be consolidated into a shared utility in
utils/permissions.py(e.g.async def verify_player_ownership(interaction, player) -> tuple[bool, str]) that both callers wrap.Notable differences to reconcile:
_verify_team_ownershipusesget_team_by_owner(ML team only);can_edit_player_imageusesget_teams_by_owner(all roster types). The shared version should useget_teams_by_ownerfor correctness._verify_team_ownershiphas anisinstance(interaction.user, discord.Member)guard on the admin check;can_edit_player_imagedoes not. The shared version should include the guard.(bool, error_message)and let callers decide how to present the error.