operation path vchannels
This commit is contained in:
parent
9a9fe62baa
commit
eda09432f4
|
@ -49,6 +49,12 @@ class OperationCreateUpdateSerializer(CustomModelSerializer):
|
||||||
exclude = EXCLUDE_FIELDS + ['number']
|
exclude = EXCLUDE_FIELDS + ['number']
|
||||||
|
|
||||||
|
|
||||||
|
class OperationPartialUpdateSerializer(CustomModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Operation
|
||||||
|
fields = ['vchannels']
|
||||||
|
|
||||||
|
|
||||||
class OperationSerializer(CustomModelSerializer):
|
class OperationSerializer(CustomModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Operation
|
model = Operation
|
||||||
|
|
|
@ -5,7 +5,8 @@ from apps.opm.serializers import (GasCheckCreateUpdateSerializer, GasCheckSerial
|
||||||
OperationCreateUpdateSerializer, OperationDetailSerializer,
|
OperationCreateUpdateSerializer, OperationDetailSerializer,
|
||||||
OplCateCreateUpdateSerializer, OplCateDetailSerializer, OplCateSerializer,
|
OplCateCreateUpdateSerializer, OplCateDetailSerializer, OplCateSerializer,
|
||||||
OplCreateUpdateSerializer, OplDetailSerializer, OplListSerializer,
|
OplCreateUpdateSerializer, OplDetailSerializer, OplListSerializer,
|
||||||
OplWorkerCreateSerializer, OplWorkerSerializer, OplWorkerUpdateSerializer)
|
OplWorkerCreateSerializer, OplWorkerSerializer, OplWorkerUpdateSerializer,
|
||||||
|
OperationPartialUpdateSerializer)
|
||||||
from apps.opm.services import close_mtask, start_mtask
|
from apps.opm.services import close_mtask, start_mtask
|
||||||
from apps.utils.viewsets import CustomGenericViewSet, CustomModelViewSet
|
from apps.utils.viewsets import CustomGenericViewSet, CustomModelViewSet
|
||||||
from rest_framework.exceptions import ParseError
|
from rest_framework.exceptions import ParseError
|
||||||
|
@ -45,13 +46,15 @@ class OperationViewSet(CustomModelViewSet):
|
||||||
|
|
||||||
def update(self, request, *args, **kwargs):
|
def update(self, request, *args, **kwargs):
|
||||||
obj = self.get_object()
|
obj = self.get_object()
|
||||||
if obj.state != Operation.OP_CREATE:
|
|
||||||
raise ParseError('非创建状态不可修改')
|
|
||||||
user = request.user
|
user = request.user
|
||||||
if user == obj.create_by or user.is_superuser:
|
if user.is_superuser:
|
||||||
|
pass
|
||||||
|
elif obj.state == Operation.OP_CREATE and user == obj.create_by:
|
||||||
|
pass
|
||||||
|
elif user == obj.create_by and kwargs['partial']:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise ParseError('非创建人不可修改')
|
raise ParseError('该作业不可修改')
|
||||||
return super().update(request, *args, **kwargs)
|
return super().update(request, *args, **kwargs)
|
||||||
|
|
||||||
def destroy(self, request, *args, **kwargs):
|
def destroy(self, request, *args, **kwargs):
|
||||||
|
@ -111,6 +114,8 @@ class OplViewSet(CustomModelViewSet):
|
||||||
开启作业监控
|
开启作业监控
|
||||||
"""
|
"""
|
||||||
obj = self.get_object()
|
obj = self.get_object()
|
||||||
|
if obj.operation.state != Operation.OP_DONE:
|
||||||
|
raise ParseError('作业已关闭,不能开启监控')
|
||||||
res = start_mtask(obj)
|
res = start_mtask(obj)
|
||||||
return Response(res)
|
return Response(res)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue