Commit b23cf6d1 authored by deepdey's avatar deepdey

chore: update get-user-logic

parent 0d503270
......@@ -21,18 +21,8 @@ def get_user_by_id_for_admin(admin_id: int, user_id: int) -> ORM.User | None:
if not admin_user:
raise Exception('User not found for mapped apiKey')
if all(
user_role.role.role_type.role_name != RoleTypeEnum.SUPER_ADMIN.value
for user_role in admin_user.user_roles
):
if all(
user_role.role.role_type.role_name != RoleTypeEnum.PROJECT_ADMIN.value
for user_role in admin_user.user_roles
):
raise Exception('You do not have permission to view user details')
else:
# return all user data for project admin for his specific project
return ORM.User.query.filter(
if admin_user.role_type.role_name != RoleTypeEnum.SUPER_ADMIN.value:
return ORM.User.query.filter(
ORM.User.is_deleted == False,
ORM.User.id == user_id,
ORM.User.project_id == admin_user.project_id
......@@ -50,21 +40,13 @@ def get_user_list_for_project_admin(admin_id: int) -> List[ORM.User]:
if not admin_user:
raise Exception('User not found for mapped apiKey')
if all(
user_role.role.role_type.role_name != RoleTypeEnum.SUPER_ADMIN.value
for user_role in admin_user.user_roles
):
if all(
user_role.role.role_type.role_name != RoleTypeEnum.PROJECT_ADMIN.value
for user_role in admin_user.user_roles
):
raise Exception('You do not have permission to view user list')
else:
# return all user data for project admin for his specific project
return ORM.User.query.filter(
if admin_user.role_type.role_name != RoleTypeEnum.SUPER_ADMIN.value:
return ORM.User.query.filter(
ORM.User.is_deleted == False,
ORM.User.project_id == admin_user.project_id
).all()
else:
# return all user data for super admin
return ORM.User.query.filter(ORM.User.is_deleted == False).all()
return ORM.User.query.filter(
ORM.User.is_deleted == False
).all()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment