Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: TT-162 Resolve some comments in the PR
  • Loading branch information
PaulRC-ioet committed Feb 25, 2021
commit 5270f88614a5d22d58a00dd2101a1c2875f6f642
47 changes: 30 additions & 17 deletions time_tracker_api/users/users_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,6 @@

ns = api.namespace('users', description='Namespace of the API for users')

# Data to check if a user is in the group
data_is_user_in_group = ns.model(
'Data',
{
'group_name': fields.String(
title='group_name',
max_length=50,
description='Name of the Group to verify',
example=Faker().word(
['time-tracker-admin', 'time-tracker-tester']
),
),
},
)

# User Model
user_response_fields = ns.model(
'User',
Expand Down Expand Up @@ -56,6 +41,33 @@
},
)

# Data to check if a user is in the group
user_in_group_input = ns.model(
'UserInGroupInput',
{
'group_name': fields.String(
title='group_name',
max_length=50,
description='Name of the Group to verify',
example=Faker().word(
['time-tracker-admin', 'time-tracker-tester']
),
),
},
)

user_in_group_response = ns.model(
'Response',
{
'value': fields.Boolean(
readOnly=True,
title='value',
description='Boolean to check if a user belong to a group',
example=Faker().boolean(),
)
},
)

user_response_fields.update(common_fields)


Expand Down Expand Up @@ -119,7 +131,8 @@ def post(self, user_id, role_id):
@ns.param('user_id', 'The user identifier')
class UserInGroup(Resource):
@ns.doc('user_in_group')
@ns.expect(data_is_user_in_group)
@ns.expect(user_in_group_input)
@ns.marshal_with(user_in_group_response)
def post(self, user_id):
"""Is User in the Group"""
"""Check if user belongs to group"""
return AzureConnection().is_user_in_group(user_id, ns.payload)