Skip to content

Commit

Permalink
Started working on confirmation of deleting administrations; bugs exi…
Browse files Browse the repository at this point in the history
…st in the template properly displaying the previously selected administrations for confirmation of delete. En route to #122.
  • Loading branch information
dgets committed May 10, 2019
1 parent 07b0adc commit 799c1d8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
25 changes: 24 additions & 1 deletion recadm/templates/recadm/delete_admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h2>Delete Administration(s)</h2>
<tr>
<td>{{ admin }}</td>
<td><center>
<input type="checkbox" name="admins" value="{{ admin.id }}" />
<input type="checkbox" name="admin_checks" value="{{ admin.id }}" />
</center></td>
</tr>
{% endfor %}
Expand All @@ -33,6 +33,29 @@ <h2>Delete Administration(s)</h2>
<input type="submit" value="Delete Administrations" />

</form>
{% elif selected_admins %}
<!-- confirm that the administrations are to be deleted -->

<h2>You are about to delete the following administrations!</h2>
<p><b>NOTE</b>: This cannot be undone!</p>

<ul>
{% for admin in selected_admins %}
<li>{{ admin }}</li>
{% endfor %}
</ul>

<form action="{% url 'recadm:delete_admin' %}" method="post">

{% csrf_token %}

<br>
<p>Clicking this box will delete these administrations (<i>forever</i>)!</p>
<br>
<input type="submit" value="Permanently Delete Administrations!" />

</form>

{% else %}
<h3>No Administrations Available!</h3>
{% endif %}
Expand Down
9 changes: 9 additions & 0 deletions recadm/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

0 comments on commit 799c1d8

Please sign in to comment.