Fakultas Ilmu Komputer UI

Commit 7a1466ac authored by Rayhan Muzakki's avatar Rayhan Muzakki 💬
Browse files

Pbi9

parent dd7c76d6
# Generated by Django 3.0.7 on 2020-11-22 07:02
# Generated by Django 3.0.7 on 2020-11-24 12:31
from decimal import Decimal
import django.core.validators
......@@ -27,19 +27,4 @@ class Migration(migrations.Migration):
name='total_profit',
field=models.DecimalField(blank=True, decimal_places=2, default=Decimal('0'), max_digits=12, null=True, validators=[django.core.validators.MinValueValidator(Decimal('0.01'))], verbose_name='total profit'),
),
migrations.AddField(
model_name='user',
name='number_of_cash_donations',
field=models.PositiveIntegerField(default=0, verbose_name='number of cash donations'),
),
migrations.AddField(
model_name='user',
name='number_of_goods_donations',
field=models.PositiveIntegerField(default=0, verbose_name='number of goods donations'),
),
migrations.AddField(
model_name='user',
name='number_of_transactions',
field=models.PositiveIntegerField(default=0, verbose_name='number of transactions'),
),
]
# Generated by Django 3.0.7 on 2020-11-24 11:32
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('api', '0003_auto_20201122_1402'),
]
operations = [
migrations.RemoveField(
model_name='user',
name='number_of_cash_donations',
),
migrations.RemoveField(
model_name='user',
name='number_of_goods_donations',
),
migrations.RemoveField(
model_name='user',
name='number_of_transactions',
),
]
......@@ -757,29 +757,6 @@ class UserTest(rest_framework_test.APITestCase):
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_user_transactionsort_list_success(self):
response = request(
'GET',
'user-list-sorttransaction',
http_authorization=self.superuser_http_authorization
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_user_cashsort_list_success(self):
response = request(
'GET',
'user-list-sortcash',
http_authorization=self.superuser_http_authorization
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_user_goodssort_list_success(self):
response = request(
'GET',
'user-list-sortgoods',
http_authorization=self.superuser_http_authorization
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_user_detail_success(self):
response = request(
......
......@@ -52,9 +52,6 @@ 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/',
......
......@@ -488,7 +488,7 @@ class UserList(generics.ListCreateAPIView):
filterset_fields = ['username', 'phone_number']
ordering_fields = [
'username', 'full_name', 'phone_number',
'number_of_transactions', 'number_of_cash_donations', 'number_of_goods_donations'
'total_transactions', 'total_program_donations_goods', 'total_program_donations_cash'
]
pagination_class = paginations.SmallResultsSetPagination
permission_classes = [rest_framework_permissions.IsAdminUser]
......@@ -496,57 +496,6 @@ 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 = [
api_permissions.IsAdminUserOrSelf,
......
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