From 799c1d82f4f2f7045616850b9b180df13375d8e1 Mon Sep 17 00:00:00 2001 From: Damon Getsman Date: Fri, 10 May 2019 02:50:50 -0500 Subject: [PATCH] Started working on confirmation of deleting administrations; bugs exist in the template properly displaying the previously selected administrations for confirmation of delete. En route to #122. --- recadm/templates/recadm/delete_admin.html | 25 ++++++++++++++++++++++- recadm/views.py | 9 ++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/recadm/templates/recadm/delete_admin.html b/recadm/templates/recadm/delete_admin.html index 4db9342..bb5023e 100644 --- a/recadm/templates/recadm/delete_admin.html +++ b/recadm/templates/recadm/delete_admin.html @@ -23,7 +23,7 @@

Delete Administration(s)

{{ admin }}
- +
{% endfor %} @@ -33,6 +33,29 @@

Delete Administration(s)

+ {% elif selected_admins %} + + +

You are about to delete the following administrations!

+

NOTE: This cannot be undone!

+ + + +
+ + {% csrf_token %} + +
+

Clicking this box will delete these administrations (forever)!

+
+ + +
+ {% else %}

No Administrations Available!

{% endif %} diff --git a/recadm/views.py b/recadm/views.py index c6ae45c..d10d966 100644 --- a/recadm/views.py +++ b/recadm/views.py @@ -330,6 +330,15 @@ def delete_admin(request): context = {} if request.method != 'POST': + # display the administrations available for deletion context['admins'] = Usage.objects.filter(user=request.user) + elif request.POST.getlist('admin_checks') is not None: + # confirm and delete the checked administrations + context['selected_admins'] = request.POST.getlist('admin_checks') + + elif request.POST['delete_confirmed'] is not None: + # now we will go ahead and wipe what has been confirmed for deletion + context['user_message'] = "Administrations deleted!" + return render(request, 'recadm/delete_admin.html', MiscMethods.add_header_info(context))