feat: operation 支持直接删除管理员操作
This commit is contained in:
parent
31f5a402c0
commit
364abe1a3b
|
@ -59,15 +59,18 @@ class OperationViewSet(CustomModelViewSet):
|
||||||
raise ParseError('该作业不可修改')
|
raise ParseError('该作业不可修改')
|
||||||
return super().update(request, *args, **kwargs)
|
return super().update(request, *args, **kwargs)
|
||||||
|
|
||||||
|
@transaction.atomic
|
||||||
def destroy(self, request, *args, **kwargs):
|
def destroy(self, request, *args, **kwargs):
|
||||||
obj = self.get_object()
|
obj = self.get_object()
|
||||||
if obj.state != Operation.OP_CREATE:
|
if user.is_superuser:
|
||||||
raise ParseError('非创建状态不可删除')
|
|
||||||
user = request.user
|
|
||||||
if user == obj.create_by or user.is_superuser:
|
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise ParseError('非创建人不可删除')
|
if obj.state != Operation.OP_CREATE:
|
||||||
|
raise ParseError('非创建状态不可删除')
|
||||||
|
user = request.user
|
||||||
|
if user != obj.create_by:
|
||||||
|
raise ParseError('非创建人不可删除')
|
||||||
|
Ticket.objects.filter(id__in=Opl.objects.filter(operation=obj).values_list('id', flat=True)).delete() # 删除可能的工单
|
||||||
obj.delete()
|
obj.delete()
|
||||||
return Response(status=204)
|
return Response(status=204)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue