update
This commit is contained in:
@@ -330,3 +330,8 @@ class AutoEvaluationSerializer(serializers.Serializer):
|
|||||||
condition = serializers.CharField()
|
condition = serializers.CharField()
|
||||||
fuel_type = serializers.CharField()
|
fuel_type = serializers.CharField()
|
||||||
mileage = serializers.CharField()
|
mileage = serializers.CharField()
|
||||||
|
|
||||||
|
class AutoEvaluationModelSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = AutoEvaluationModel
|
||||||
|
fields = "__all__"
|
||||||
@@ -128,3 +128,7 @@ class CreateQuickevaluationSerializer(serializers.ModelSerializer):
|
|||||||
return super().create(validated_data)
|
return super().create(validated_data)
|
||||||
|
|
||||||
|
|
||||||
|
class QuickEvaluationModelSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = QuickEvaluationModel
|
||||||
|
fields = '__all__'
|
||||||
@@ -37,6 +37,7 @@ urlpatterns = [
|
|||||||
# Quick Evaluation
|
# Quick Evaluation
|
||||||
path('quick-evaluation/', include(
|
path('quick-evaluation/', include(
|
||||||
[
|
[
|
||||||
|
path("admin/", views.AdminQuickEvalAPIView.as_view(), name="quick-evaluation"),
|
||||||
path(
|
path(
|
||||||
'archive/', include(
|
'archive/', include(
|
||||||
[
|
[
|
||||||
@@ -51,6 +52,7 @@ urlpatterns = [
|
|||||||
# Auto Evaluation
|
# Auto Evaluation
|
||||||
path("auto-evaluation/", include(
|
path("auto-evaluation/", include(
|
||||||
[
|
[
|
||||||
|
path("admin/", views.AdminEvaluationsAPIView.as_view(), name="admin-evaluations"),
|
||||||
path('archive/', include(
|
path('archive/', include(
|
||||||
[
|
[
|
||||||
path('<int:pk>/', views.AutoEvaluationArchiveAPIView.as_view()),
|
path('<int:pk>/', views.AutoEvaluationArchiveAPIView.as_view()),
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django_core.mixins import BaseViewSetMixin
|
from django_core.mixins import BaseViewSetMixin
|
||||||
|
|
||||||
from django_filters.rest_framework import DjangoFilterBackend
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
from drf_spectacular.utils import extend_schema, OpenApiParameter
|
from drf_spectacular.utils import extend_schema, OpenApiParameter
|
||||||
|
from rest_framework import generics
|
||||||
from rest_framework.filters import OrderingFilter, SearchFilter
|
from rest_framework.filters import OrderingFilter, SearchFilter
|
||||||
from rest_framework.generics import GenericAPIView, ListAPIView
|
from rest_framework.generics import GenericAPIView, ListAPIView
|
||||||
from rest_framework.permissions import AllowAny, IsAuthenticated
|
from rest_framework.permissions import AllowAny, IsAuthenticated
|
||||||
@@ -12,10 +11,12 @@ from rest_framework.response import Response
|
|||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
from rest_framework.viewsets import ModelViewSet
|
from rest_framework.viewsets import ModelViewSet
|
||||||
|
|
||||||
|
from core.apps.accounts.choices import RoleChoice
|
||||||
from core.apps.accounts.serializers.user import UserSerializer
|
from core.apps.accounts.serializers.user import UserSerializer
|
||||||
from core.apps.evaluation.filters.auto import AutoevaluationFilter
|
from core.apps.evaluation.filters.auto import AutoevaluationFilter
|
||||||
from core.apps.evaluation.models import AutoEvaluationModel
|
from core.apps.evaluation.models import AutoEvaluationModel
|
||||||
from core.apps.evaluation.serializers import auto as serializers
|
from core.apps.evaluation.serializers import auto as serializers, AutoEvaluationModelSerializer
|
||||||
|
|
||||||
|
|
||||||
@extend_schema(tags=["AutoEvaluation"])
|
@extend_schema(tags=["AutoEvaluation"])
|
||||||
class AutoEvaluationView(BaseViewSetMixin, ModelViewSet):
|
class AutoEvaluationView(BaseViewSetMixin, ModelViewSet):
|
||||||
@@ -175,3 +176,16 @@ class AutoEvaluationArchiveAPIView(APIView):
|
|||||||
},
|
},
|
||||||
status=200
|
status=200
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@extend_schema(tags=["AutoEvaluation"])
|
||||||
|
class AdminEvaluationsAPIView(generics.GenericAPIView):
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
def get(self, request):
|
||||||
|
if request.user.role != RoleChoice.ADMIN:
|
||||||
|
return Response({'detail': 'Forbidden'}, status=403)
|
||||||
|
auto_eval = AutoEvaluationModel.objects.filter(
|
||||||
|
created_by=self.request.user
|
||||||
|
).select_related('appraisers').distinct()
|
||||||
|
serializer = AutoEvaluationModelSerializer(auto_eval, many=True)
|
||||||
|
return Response(serializer.data)
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
# django
|
# django
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
|
|
||||||
# django core
|
# django core
|
||||||
from django_core.mixins import BaseViewSetMixin
|
from django_core.mixins import BaseViewSetMixin
|
||||||
|
|
||||||
# django filters
|
# django filters
|
||||||
from django_filters.rest_framework import DjangoFilterBackend
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
|
|
||||||
# swagger
|
# swagger
|
||||||
from drf_spectacular.utils import extend_schema
|
from drf_spectacular.utils import extend_schema
|
||||||
|
|
||||||
# rest framework
|
# rest framework
|
||||||
from rest_framework import status
|
from rest_framework import status, generics
|
||||||
from rest_framework.filters import OrderingFilter, SearchFilter
|
from rest_framework.filters import OrderingFilter, SearchFilter
|
||||||
from rest_framework.generics import ListAPIView
|
from rest_framework.generics import ListAPIView
|
||||||
from rest_framework.parsers import FormParser, MultiPartParser
|
from rest_framework.parsers import FormParser, MultiPartParser
|
||||||
@@ -20,10 +16,11 @@ from rest_framework.response import Response
|
|||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
from rest_framework.viewsets import ModelViewSet
|
from rest_framework.viewsets import ModelViewSet
|
||||||
|
|
||||||
|
from core.apps.accounts.choices import RoleChoice
|
||||||
# core apps
|
# core apps
|
||||||
from core.apps.evaluation.filters.quick import QuickevaluationFilter
|
from core.apps.evaluation.filters.quick import QuickevaluationFilter
|
||||||
from core.apps.evaluation.models import QuickEvaluationModel
|
from core.apps.evaluation.models import QuickEvaluationModel
|
||||||
from core.apps.evaluation.serializers import quick as serializers
|
from core.apps.evaluation.serializers import quick as serializers, QuickEvaluationModelSerializer
|
||||||
|
|
||||||
|
|
||||||
@extend_schema(tags=["QuickEvaluation"])
|
@extend_schema(tags=["QuickEvaluation"])
|
||||||
@@ -87,3 +84,18 @@ class QuickEvaluationArchivedListAPIView(ListAPIView):
|
|||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return QuickEvaluationModel.objects.filter(is_archive=True)
|
return QuickEvaluationModel.objects.filter(is_archive=True)
|
||||||
|
|
||||||
|
|
||||||
|
@extend_schema(tags=["QuickEvaluation"])
|
||||||
|
class AdminQuickEvalAPIView(generics.GenericAPIView):
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
def get(self, request):
|
||||||
|
if request.user.role != RoleChoice.ADMIN:
|
||||||
|
return Response({'detail': 'Forbidden'}, status=403)
|
||||||
|
quick_eval = QuickEvaluationModel.objects.filter(
|
||||||
|
created_by=self.request.user
|
||||||
|
).select_related('created_by').distinct()
|
||||||
|
serializer = QuickEvaluationModelSerializer(quick_eval, many=True)
|
||||||
|
|
||||||
|
return Response(serializer.data)
|
||||||
|
|||||||
Reference in New Issue
Block a user