From 2bcb0cae74f5035686a59832c1dd7bd40d4e3a35 Mon Sep 17 00:00:00 2001 From: Findeton Date: Mon, 18 Nov 2024 13:51:37 +0800 Subject: [PATCH] wip --- iam/api/views.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/iam/api/views.py b/iam/api/views.py index eaeb0671..e23e801b 100644 --- a/iam/api/views.py +++ b/iam/api/views.py @@ -3382,6 +3382,25 @@ def post(request, pk=None): status=400, error_codename=ErrorCodes.BAD_REQUEST) + for election_id in election_ids: + permission_required(request.user, 'AuthEvent', ['edit', 'delete'], pk) + + election_obj = AuthEvent.objects.get(pk=election_id) + + action = Action( + executer=request.user, + receiver=None, + action_name="authevent:delete", + event=election_obj, + metadata=dict( + auth_event_id=election_obj.id, + auth_event_name=election_obj.name + ) + ) + + action.save() + election_obj.delete() + data = {'status': 'ok'} return json_response(data)