Skip to content

Commit

Permalink
Merge branch 'AL-python-serverless' into AL-python-serverless-scan-tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
aloftus23 committed Oct 2, 2024
2 parents 7dc048d + bfbee9b commit 0b680ec
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions backend/src/xfd_django/xfd_api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,23 @@ def is_regional_admin(current_user) -> bool:
"""Check if the user has regional admin permissions."""
return current_user and current_user.userType in ["regionalAdmin", "globalAdmin"]

def get_tag_organizations(current_user, tag_id: str) -> list[str]:
"""Returns the organizations belonging to a tag, if the user can access the tag."""
# Check if the user is a global view admin
if not is_global_view_admin(current_user):
return []

# Fetch the OrganizationTag and its related organizations
tag = OrganizationTag.objects.prefetch_related("organizations").filter(id=tag_id).first()
if tag:
# Return a list of organization IDs
return [org.id for org in tag.organizations.all()]

# Return an empty list if tag is not found
return []




def get_tag_organizations(current_user, tag_id: str) -> list[str]:
"""Returns the organizations belonging to a tag, if the user can access the tag."""
Expand Down

0 comments on commit 0b680ec

Please sign in to comment.