Skip to content

Commit

Permalink
Fix project access in dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
bud42 committed Sep 15, 2023
1 parent c7318bf commit e0ef11f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions garjus/utils_xnat.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,25 @@ def get_my_projects(xnat):
logger.debug(uri)
json_data = json.loads(xnat._exec(uri, 'GET'), strict=False)
result = json_data['ResultSet']['Result']
_roles = ['Owners', 'Members', 'Collaborators']
return [x['id'] for x in result if x['user_role_6'] in _roles]
roles = ['Owners', 'Members', 'Collaborators']

if len(result) == 0:
return []

user_role_column = None
# Search for user role column
for k in result[0].keys():
if k.startswith('user_role_'):
user_role_column = k
break

if user_role_column is None:
logger.info(f'could not determine user role column')
return []

logger.debug(f'user role column:{user_role_column}')

return [x['id'] for x in result if x[user_role_column] in roles]


def get_my_favorites(xnat):
Expand Down

0 comments on commit e0ef11f

Please sign in to comment.