Skip to content

Commit

Permalink
FEATURE: new GET query filter in user view ('in' filter)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbannon committed Feb 9, 2017
1 parent f8c5152 commit 9d1f839
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rodan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

# Module version following PEP 396
# Get version: import rodan; rodan.__version__
__version__ = "1.1.4"
__version__ = "1.1.5"

__copyright__ = "Copyright 2011-2016 Distributed Digital Music Archives & Libraries Lab"
__copyright__ = "Copyright 2011-2017 Distributed Digital Music Archives & Libraries Lab"


# This will make sure the app is always imported when
Expand Down
14 changes: 14 additions & 0 deletions rodan/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from rodan.permissions import CustomObjectPermissions
from rodan.serializers.user import UserSerializer, UserListSerializer

import django_filters

class UserList(generics.ListCreateAPIView):
"""
Expand All @@ -27,6 +28,19 @@ class UserList(generics.ListCreateAPIView):
_ignore_model_permissions = True
serializer_class = UserListSerializer

class filter_class(django_filters.FilterSet):
username__in = django_filters.MethodFilter()

def filter_username__in(self, q, v):
vs = v.split(',')
return q.filter(username__in=vs)

class Meta:
model = User
fields = {
"username": ['in']
}

def get_queryset(self):
queryset = User.objects.exclude(pk=-1)
return queryset
Expand Down

0 comments on commit 9d1f839

Please sign in to comment.