48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
from rest_framework import viewsets
|
|
from rest_framework.parsers import FormParser, JSONParser, MultiPartParser
|
|
|
|
from requests_app.models import Request as EmployeeRequest
|
|
|
|
from .viewsets import (
|
|
RequestCommentsMixin,
|
|
RequestCoreMixin,
|
|
RequestNotificationsMixin,
|
|
RequestStatisticsMixin,
|
|
RequestVacationMixin,
|
|
RequestWorkflowMixin,
|
|
)
|
|
|
|
|
|
class RequestViewSet(
|
|
RequestCoreMixin,
|
|
RequestCommentsMixin,
|
|
RequestWorkflowMixin,
|
|
RequestVacationMixin,
|
|
RequestStatisticsMixin,
|
|
RequestNotificationsMixin,
|
|
viewsets.ModelViewSet,
|
|
):
|
|
"""ViewSet для заявок сотрудников.
|
|
|
|
Обычный UI/API работает по строгим правилам участников:
|
|
автор, прямые получатели и пользователи в копии.
|
|
|
|
Поддерживаемые экшены:
|
|
- POST /requests/{id}/approve/
|
|
- POST /requests/{id}/reject/
|
|
- POST /requests/{id}/cancel/
|
|
- GET/POST /requests/{id}/comments/
|
|
|
|
Raises:
|
|
PermissionDenied: При нарушении правил доступа.
|
|
"""
|
|
|
|
queryset = EmployeeRequest.objects.select_related(
|
|
"employee",
|
|
"approver",
|
|
"department",
|
|
"vacation_terms__recorded_by",
|
|
"vacation_terms__finance_instruction",
|
|
).order_by("-created_at")
|
|
parser_classes = (MultiPartParser, FormParser, JSONParser)
|