From 540679df11e1772785981a2519663d0a2bb3fd75 Mon Sep 17 00:00:00 2001 From: feng626 <1304903146@qq.com> Date: Mon, 14 Feb 2022 10:57:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Doperatelog=20add=20rem?= =?UTF-8?q?ove=20=E7=BF=BB=E8=AF=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/audits/signals_handler.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/audits/signals_handler.py b/apps/audits/signals_handler.py index 3e5086831..0f9356066 100644 --- a/apps/audits/signals_handler.py +++ b/apps/audits/signals_handler.py @@ -170,9 +170,9 @@ M2M_NEED_RECORD = { } M2M_ACTION = { - POST_ADD: 'add', - POST_REMOVE: 'remove', - POST_CLEAR: 'remove', + POST_ADD: OperateLog.ACTION_CREATE, + POST_REMOVE: OperateLog.ACTION_DELETE, + POST_CLEAR: OperateLog.ACTION_DELETE, } @@ -187,14 +187,14 @@ def on_m2m_changed(sender, action, instance, reverse, model, pk_set, **kwargs): sender_name = sender._meta.object_name if sender_name in M2M_NEED_RECORD: - action = M2M_ACTION[action] org_id = current_org.id remote_addr = get_request_ip(current_request) user = str(user) resource_type, resource_tmpl_add, resource_tmpl_remove = M2M_NEED_RECORD[sender_name] - if action == 'add': + action = M2M_ACTION[action] + if action == OperateLog.ACTION_CREATE: resource_tmpl = resource_tmpl_add - elif action == 'remove': + elif action == OperateLog.ACTION_DELETE: resource_tmpl = resource_tmpl_remove to_create = []