feat: mlog 变化不再创建日志
This commit is contained in:
parent
84f7de61bc
commit
d52bd4e064
|
@ -160,17 +160,17 @@ class MlogViewSet(CustomModelViewSet):
|
||||||
'material_in__number', 'material_in__specification', 'batch', 'material_in__model',
|
'material_in__number', 'material_in__specification', 'batch', 'material_in__model',
|
||||||
'material_out__name', 'material_out__number', 'material_out__specification', 'material_out__model',]
|
'material_out__name', 'material_out__number', 'material_out__specification', 'material_out__model',]
|
||||||
|
|
||||||
@transaction.atomic
|
# @transaction.atomic
|
||||||
def perform_create(self, serializer):
|
# def perform_create(self, serializer):
|
||||||
ins = serializer.save()
|
# ins = serializer.save()
|
||||||
data = MlogSerializer(ins).data
|
# data = MlogSerializer(ins).data
|
||||||
create_auditlog('create', ins, data)
|
# create_auditlog('create', ins, data)
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def perform_destroy(self, instance):
|
def perform_destroy(self, instance):
|
||||||
if instance.submit_time is not None:
|
if instance.submit_time is not None:
|
||||||
raise ParseError('日志已提交不可变动')
|
raise ParseError('日志已提交不可变动')
|
||||||
delete_auditlog(instance, instance.id)
|
# delete_auditlog(instance, instance.id)
|
||||||
instance.delete()
|
instance.delete()
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
|
@ -178,10 +178,10 @@ class MlogViewSet(CustomModelViewSet):
|
||||||
ins = serializer.instance
|
ins = serializer.instance
|
||||||
if ins.submit_time is not None:
|
if ins.submit_time is not None:
|
||||||
raise ParseError('该日志已提交!')
|
raise ParseError('该日志已提交!')
|
||||||
val_old = MlogSerializer(instance=ins).data
|
# val_old = MlogSerializer(instance=ins).data
|
||||||
serializer.save()
|
serializer.save()
|
||||||
val_new = MlogSerializer(instance=ins).data
|
# val_new = MlogSerializer(instance=ins).data
|
||||||
create_auditlog('update', ins, val_new, val_old)
|
# create_auditlog('update', ins, val_new, val_old)
|
||||||
|
|
||||||
@action(methods=['post'], detail=False, perms_map={'post': 'mlog.init'}, serializer_class=MlogInitSerializer)
|
@action(methods=['post'], detail=False, perms_map={'post': 'mlog.init'}, serializer_class=MlogInitSerializer)
|
||||||
def init(self, request, *args, **kwargs):
|
def init(self, request, *args, **kwargs):
|
||||||
|
@ -213,7 +213,6 @@ class MlogViewSet(CustomModelViewSet):
|
||||||
日志提交
|
日志提交
|
||||||
"""
|
"""
|
||||||
ins: Mlog = self.get_object()
|
ins: Mlog = self.get_object()
|
||||||
vdata_old = MlogSerializer(ins).data
|
|
||||||
now = timezone.now()
|
now = timezone.now()
|
||||||
if ins.ticket:
|
if ins.ticket:
|
||||||
raise ParseError('该日志存在审批!')
|
raise ParseError('该日志存在审批!')
|
||||||
|
@ -225,8 +224,8 @@ class MlogViewSet(CustomModelViewSet):
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
mlog_submit(ins, self.request.user, now)
|
mlog_submit(ins, self.request.user, now)
|
||||||
vdata_new = MlogSerializer(ins).data
|
vdata_new = MlogSerializer(ins).data
|
||||||
create_auditlog('submit', ins, vdata_new,
|
# create_auditlog('submit', ins, vdata_new,
|
||||||
vdata_old, now, self.request.user)
|
# vdata_old, now, self.request.user)
|
||||||
MyThread(target=cal_mtask_progress_from_mlog,args=(ins,)).start()
|
MyThread(target=cal_mtask_progress_from_mlog,args=(ins,)).start()
|
||||||
MyThread(target=cal_material_count_from_mlog,args=(ins,)).start()
|
MyThread(target=cal_material_count_from_mlog,args=(ins,)).start()
|
||||||
return Response(vdata_new)
|
return Response(vdata_new)
|
||||||
|
@ -246,8 +245,8 @@ class MlogViewSet(CustomModelViewSet):
|
||||||
now = timezone.now()
|
now = timezone.now()
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
mlog_revert(ins, user, now)
|
mlog_revert(ins, user, now)
|
||||||
create_auditlog('revert', ins, {}, {}, now, user,
|
# create_auditlog('revert', ins, {}, {}, now, user,
|
||||||
request.data.get('change_reason', ''))
|
# request.data.get('change_reason', ''))
|
||||||
MyThread(target=cal_mtask_progress_from_mlog,args=(ins,)).start()
|
MyThread(target=cal_mtask_progress_from_mlog,args=(ins,)).start()
|
||||||
MyThread(target=cal_material_count_from_mlog,args=(ins,)).start()
|
MyThread(target=cal_material_count_from_mlog,args=(ins,)).start()
|
||||||
return Response(MlogSerializer(instance=ins).data)
|
return Response(MlogSerializer(instance=ins).data)
|
||||||
|
|
Loading…
Reference in New Issue