From 87cb48f15b8dcd32ce5ae133bee76b63d3f35717 Mon Sep 17 00:00:00 2001 From: sichan Date: Mon, 17 Jun 2024 10:48:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E5=88=A0=E9=99=A4accountf?= =?UTF-8?q?ile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accounts/templates/accounts/user_permissions_list.html | 2 +- application/accounts/views.py | 4 ++++ templates/delete_modal.html | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/application/accounts/templates/accounts/user_permissions_list.html b/application/accounts/templates/accounts/user_permissions_list.html index 966c68f..0d5816e 100644 --- a/application/accounts/templates/accounts/user_permissions_list.html +++ b/application/accounts/templates/accounts/user_permissions_list.html @@ -65,7 +65,7 @@ id="deleteBtn" class="delete-btn" style="color: red" - data-target_id="{{ item.id }}" + data-id="{{ item.id }}" data-bs-toggle="modal" data-bs-target="#deleteModal">删除 diff --git a/application/accounts/views.py b/application/accounts/views.py index 3bec2be..f785398 100644 --- a/application/accounts/views.py +++ b/application/accounts/views.py @@ -197,8 +197,12 @@ def user_permissions_list(request): def delete_account_profile(request): if request.method == 'GET': user_id = request.GET.get('id') + if not user_id: + return JsonResponse({"message": "缺少id参数"}, status=400) + AccountProfile.objects.filter(user_id=user_id).delete() return JsonResponse({"message": "删除成功"}) + return JsonResponse({"message": "无效的请求方法"}, status=405) diff --git a/templates/delete_modal.html b/templates/delete_modal.html index 295bb35..d56ca26 100644 --- a/templates/delete_modal.html +++ b/templates/delete_modal.html @@ -29,8 +29,8 @@ if (event.target.id === 'deleteBtn') { // 打开删除模态框 targetIdToDelete = $(this).data('id'); - $('#deleteModal').modal('show'); debugger + $('#deleteModal').modal('show'); } else if (event.target.id === 'confirmDeleteBtn') { // 确认删除 if (targetIdToDelete !== null) {