77 lines
3.1 KiB
Python
77 lines
3.1 KiB
Python
from django_core.mixins import BaseViewSetMixin
|
|
from django_filters.rest_framework import DjangoFilterBackend
|
|
from drf_spectacular.utils import OpenApiParameter, extend_schema
|
|
from rest_framework.filters import OrderingFilter
|
|
from rest_framework.permissions import AllowAny
|
|
from rest_framework.viewsets import ReadOnlyModelViewSet
|
|
|
|
from core.apps.evaluation.filters.history import (
|
|
AutoevaluationhistoryFilter,
|
|
QuickevaluationhistoryFilter,
|
|
)
|
|
from core.apps.evaluation.models import AutoevaluationhistoryModel, QuickevaluationhistoryModel
|
|
from core.apps.evaluation.serializers.history import (
|
|
CreateAutoevaluationhistorySerializer,
|
|
CreateQuickevaluationhistorySerializer,
|
|
ListAutoevaluationhistorySerializer,
|
|
ListQuickevaluationhistorySerializer,
|
|
RetrieveAutoevaluationhistorySerializer,
|
|
RetrieveQuickevaluationhistorySerializer,
|
|
)
|
|
|
|
|
|
@extend_schema(
|
|
tags=["AutoEvaluationHistory"],
|
|
parameters=[
|
|
OpenApiParameter("auto_evaluation", int, description="AutoEvaluation ID bo'yicha filter"),
|
|
OpenApiParameter("event_type", str, description="Event turi bo'yicha filter"),
|
|
OpenApiParameter("created_from", str, description="Boshlanish sanasi (ISO 8601)"),
|
|
OpenApiParameter("created_to", str, description="Tugash sanasi (ISO 8601)"),
|
|
],
|
|
)
|
|
class AutoEvaluationHistoryView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
|
queryset = AutoevaluationhistoryModel.objects.select_related().all()
|
|
serializer_class = ListAutoevaluationhistorySerializer
|
|
permission_classes = [AllowAny]
|
|
pagination_class = None # History uchun pagination kerak emas
|
|
|
|
filter_backends = [DjangoFilterBackend, OrderingFilter]
|
|
filterset_class = AutoevaluationhistoryFilter
|
|
ordering_fields = ["created_at"]
|
|
ordering = ["created_at"]
|
|
|
|
action_permission_classes = {}
|
|
action_serializer_class = {
|
|
"list": ListAutoevaluationhistorySerializer,
|
|
"retrieve": RetrieveAutoevaluationhistorySerializer,
|
|
"create": CreateAutoevaluationhistorySerializer,
|
|
}
|
|
|
|
|
|
@extend_schema(
|
|
tags=["QuickEvaluationHistory"],
|
|
parameters=[
|
|
OpenApiParameter("quick_evaluation", int, description="QuickEvaluation ID bo'yicha filter"),
|
|
OpenApiParameter("event_type", str, description="Event turi bo'yicha filter"),
|
|
OpenApiParameter("created_from", str, description="Boshlanish sanasi (ISO 8601)"),
|
|
OpenApiParameter("created_to", str, description="Tugash sanasi (ISO 8601)"),
|
|
],
|
|
)
|
|
class QuickEvaluationHistoryView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
|
queryset = QuickevaluationhistoryModel.objects.select_related().all()
|
|
serializer_class = ListQuickevaluationhistorySerializer
|
|
permission_classes = [AllowAny]
|
|
pagination_class = None # History uchun pagination kerak emas
|
|
|
|
filter_backends = [DjangoFilterBackend, OrderingFilter]
|
|
filterset_class = QuickevaluationhistoryFilter
|
|
ordering_fields = ["created_at"]
|
|
ordering = ["created_at"]
|
|
|
|
action_permission_classes = {}
|
|
action_serializer_class = {
|
|
"list": ListQuickevaluationhistorySerializer,
|
|
"retrieve": RetrieveQuickevaluationhistorySerializer,
|
|
"create": CreateQuickevaluationhistorySerializer,
|
|
}
|