feat: add mechnic-auto-model
This commit is contained in:
@@ -16,9 +16,14 @@ from rest_framework.viewsets import ReadOnlyModelViewSet
|
||||
# core apps
|
||||
from core.apps.evaluation.filters.history import (
|
||||
AutoevaluationhistoryFilter,
|
||||
MechanicAutoevaluationhistoryFilter,
|
||||
QuickevaluationhistoryFilter,
|
||||
)
|
||||
from core.apps.evaluation.models import AutoevaluationhistoryModel, QuickevaluationhistoryModel
|
||||
from core.apps.evaluation.models import (
|
||||
AutoevaluationhistoryModel,
|
||||
MechanicAutoevaluationhistoryModel,
|
||||
QuickevaluationhistoryModel,
|
||||
)
|
||||
from core.apps.evaluation.serializers import history as serializers
|
||||
|
||||
|
||||
@@ -72,6 +77,56 @@ class AutoEvaluationHistoryView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
||||
})
|
||||
|
||||
|
||||
@extend_schema(
|
||||
tags=["MechanicAutoEvaluationHistory"],
|
||||
parameters=[
|
||||
OpenApiParameter("mechanic_auto_evaluation", int, description="MechanicAutoEvaluation 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 MechanicAutoEvaluationHistoryView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
||||
queryset = MechanicAutoevaluationhistoryModel.objects.only(
|
||||
"id", "mechanic_auto_evaluation_id", "event_type",
|
||||
"actor_id", "actor_full_name", "actor_role",
|
||||
"meta", "created_at",
|
||||
)
|
||||
serializer_class = serializers.ListMechanicAutoevaluationhistorySerializer
|
||||
permission_classes = [AllowAny]
|
||||
pagination_class = None
|
||||
|
||||
filter_backends = [DjangoFilterBackend, OrderingFilter]
|
||||
filterset_class = MechanicAutoevaluationhistoryFilter
|
||||
ordering_fields = [
|
||||
"id",
|
||||
"event_type",
|
||||
"event_type_display",
|
||||
"actor",
|
||||
"meta",
|
||||
"created_at",
|
||||
]
|
||||
ordering = ["created_at"]
|
||||
|
||||
action_permission_classes = {}
|
||||
action_serializer_class = {
|
||||
"list": serializers.ListMechanicAutoevaluationhistorySerializer,
|
||||
"retrieve": serializers.RetrieveMechanicAutoevaluationhistorySerializer,
|
||||
"create": serializers.CreateMechanicAutoevaluationhistorySerializer,
|
||||
}
|
||||
|
||||
def list(self, request, *args, **kwargs):
|
||||
queryset = self.filter_queryset(self.get_queryset())
|
||||
results = list(queryset)
|
||||
serializer = self.get_serializer(results, many=True)
|
||||
return Response({
|
||||
"count": len(results),
|
||||
"next": None,
|
||||
"previous": None,
|
||||
"results": serializer.data,
|
||||
})
|
||||
|
||||
|
||||
@extend_schema(
|
||||
tags=["QuickEvaluationHistory"],
|
||||
parameters=[
|
||||
|
||||
Reference in New Issue
Block a user