Skip to content

Commit

Permalink
framework: Update users API
Browse files Browse the repository at this point in the history
- Fetches only active users
  • Loading branch information
harshithpabbati committed Feb 14, 2020
1 parent eeb27e3 commit a7050aa
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions framework/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class Query(
):
user = graphene.Field(UserObj, username=graphene.String(required=True))
users = graphene.List(UserObj, sort=graphene.String())
activeUsers = graphene.List(UserObj, sort=graphene.String())
isClubMember = graphene.Boolean()
getInActiveUsers = graphene.List(UserType)

Expand All @@ -234,6 +235,12 @@ def resolve_users(self, info, **kwargs):
sort = 'username'
return User.objects.values().all().order_by(sort)

def resolve_activeUsers(self, info, **kwargs):
sort = kwargs.get('sort')
if sort is None:
sort = 'username'
return User.objects.filter(is_active=True).order_by(sort)

def resolve_isClubMember(self, info, **kwargs):
user = info.context.user
if Profile.objects.filter(user=user).count() == 0:
Expand Down

0 comments on commit a7050aa

Please sign in to comment.