Skip to content

Commit

Permalink
[#3734] Add can_manage_users field on the /rest/v1/me end-point
Browse files Browse the repository at this point in the history
  • Loading branch information
punchagan committed Aug 14, 2019
1 parent f2e9115 commit df5e199
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 43 deletions.
5 changes: 5 additions & 0 deletions akvo/rest/serializers/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class UserSerializer(BaseRSRSerializer):
# Legacy fields to support Tastypie API emulation
legacy_org = serializers.SerializerMethodField()
username = serializers.SerializerMethodField()
can_manage_users = serializers.SerializerMethodField()

class Meta:
model = get_user_model()
Expand All @@ -61,6 +62,7 @@ class Meta:
'is_admin',
'is_support',
'is_superuser',
'can_manage_users',
'organisation',
'organisations',
'approved_employments',
Expand Down Expand Up @@ -93,6 +95,9 @@ def get_legacy_org(self, obj):
def get_username(self, obj):
return obj.email

def get_can_manage_users(self, obj):
return obj.has_perm('rsr.user_management')


class UserPasswordSerializer(serializers.Serializer):
"""Change password serializer"""
Expand Down
Loading

0 comments on commit df5e199

Please # to comment.