Fakultas Ilmu Komputer UI

Commit f2360f18 authored by rayhan muzakki's avatar rayhan muzakki
Browse files

[GREEN] passed test for user order lists

parent 101c3182
......@@ -52,7 +52,9 @@ urlpatterns = [
),
urls.path('users/', api_views.UserList.as_view(), name='user-list'),
urls.path('users/sorttransaction', api_views.UserListTransaction.as_view(), name='user-list-sorttransaction'),
urls.path('users/sortcash', api_views.UserListCash.as_view(), name='user-list-sortcash'),
urls.path('users/sortgoods', api_views.UserListGoods.as_view(), name='user-list-sortgoods'),
urls.path('users/<str:pk>/', api_views.UserDetail.as_view(), name='user-detail'),
urls.path(
'bank-account-transfer-destinations/',
......
......@@ -499,7 +499,56 @@ class UserList(generics.ListCreateAPIView):
search_fields = ['username', 'full_name', 'phone_number']
serializer_class = api_serializers.UserSerializer
class UserListTransaction(generics.ListCreateAPIView):
filter_backends = [
rest_framework.DjangoFilterBackend,
rest_framework_filters.OrderingFilter,
rest_framework_filters.SearchFilter,
]
filterset_fields = ['username', 'phone_number']
ordering_fields = [
'username', 'full_name', 'phone_number',
'number_of_transactions', 'number_of_cash_donations', 'number_of_goods_donations'
]
pagination_class = paginations.SmallResultsSetPagination
permission_classes = [rest_framework_permissions.IsAdminUser]
queryset = models.User.objects.all().order_by('-number_of_transactions')
search_fields = ['username', 'full_name', 'phone_number']
serializer_class = api_serializers.UserSerializer
class UserListCash(generics.ListCreateAPIView):
filter_backends = [
rest_framework.DjangoFilterBackend,
rest_framework_filters.OrderingFilter,
rest_framework_filters.SearchFilter,
]
filterset_fields = ['username', 'phone_number']
ordering_fields = [
'username', 'full_name', 'phone_number',
'number_of_transactions', 'number_of_cash_donations', 'number_of_goods_donations'
]
pagination_class = paginations.SmallResultsSetPagination
permission_classes = [rest_framework_permissions.IsAdminUser]
queryset = models.User.objects.all().order_by('-number_of_cash_donations')
search_fields = ['username', 'full_name', 'phone_number']
serializer_class = api_serializers.UserSerializer
class UserListGoods(generics.ListCreateAPIView):
filter_backends = [
rest_framework.DjangoFilterBackend,
rest_framework_filters.OrderingFilter,
rest_framework_filters.SearchFilter,
]
filterset_fields = ['username', 'phone_number']
ordering_fields = [
'username', 'full_name', 'phone_number',
'number_of_transactions', 'number_of_cash_donations', 'number_of_goods_donations'
]
pagination_class = paginations.SmallResultsSetPagination
permission_classes = [rest_framework_permissions.IsAdminUser]
queryset = models.User.objects.all().order_by('-number_of_goods_donations')
search_fields = ['username', 'full_name', 'phone_number']
serializer_class = api_serializers.UserSerializer
class UserDetail(generics.RetrieveUpdateDestroyAPIView):
permission_classes = [
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment