Fakultas Ilmu Komputer UI

Commit a83d3347 authored by Dave Nathanael's avatar Dave Nathanael
Browse files

[REFACTOR] Make separate field constant for CaseSubject ordering filter

parent 53b06d5f
Pipeline #40889 failed with stages
in 1 minute and 26 seconds
...@@ -9,7 +9,6 @@ CASE_SUBJECT_FILTERSET_FIELDS = [ ...@@ -9,7 +9,6 @@ CASE_SUBJECT_FILTERSET_FIELDS = [
"address", "address",
"district", "district",
"sub_district", "sub_district",
"created_at",
] ]
CASE_SUBJECT_SEARCH_FIELDS = [ CASE_SUBJECT_SEARCH_FIELDS = [
...@@ -21,6 +20,15 @@ CASE_SUBJECT_SEARCH_FIELDS = [ ...@@ -21,6 +20,15 @@ CASE_SUBJECT_SEARCH_FIELDS = [
"created_at", "created_at",
] ]
CASE_SUBJECT_ORDERING_FIELDS = [
"name",
"age",
"is_male",
"address",
"district",
"sub_district",
"created_at",
]
class InvestigationCaseFilter(FilterSet): class InvestigationCaseFilter(FilterSet):
class Meta: class Meta:
......
...@@ -26,6 +26,7 @@ from apps.cases.serializers import ( ...@@ -26,6 +26,7 @@ from apps.cases.serializers import (
from apps.cases.filters import ( from apps.cases.filters import (
CASE_SUBJECT_FILTERSET_FIELDS, CASE_SUBJECT_FILTERSET_FIELDS,
CASE_SUBJECT_SEARCH_FIELDS, CASE_SUBJECT_SEARCH_FIELDS,
CASE_SUBJECT_ORDERING_FIELDS,
InvestigationCaseFilter, InvestigationCaseFilter,
MonitoringCaseFilter, MonitoringCaseFilter,
) )
...@@ -49,7 +50,7 @@ class CaseSubjectViewSet(viewsets.ModelViewSet): ...@@ -49,7 +50,7 @@ class CaseSubjectViewSet(viewsets.ModelViewSet):
permission_classes = (IsAuthorOrAdministrator,) permission_classes = (IsAuthorOrAdministrator,)
pagination_class = PageNumberPagination pagination_class = PageNumberPagination
search_fields = CASE_SUBJECT_SEARCH_FIELDS search_fields = CASE_SUBJECT_SEARCH_FIELDS
ordering_fields = CASE_SUBJECT_FILTERSET_FIELDS ordering_fields = CASE_SUBJECT_ORDERING_FIELDS
class InvestigationCaseViewSet(viewsets.ViewSet): class InvestigationCaseViewSet(viewsets.ViewSet):
......
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