Skip to content

Commit

Permalink
last admin cannot be deleted
Browse files Browse the repository at this point in the history
no backend validation, no identification if its himself
  • Loading branch information
janik committed Aug 10, 2024
1 parent d24b1f5 commit 6e81e2d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion quafelweb/account_controller/templates/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
<form action="delete/" class='account_entry' method='post'>
{% csrf_token %}
<p>{{ account.identifier }}</p>
<button class='icon_button' name="admin_ident" value={{account.identifier}}><span class="material-symbols-outlined">delete</span></button>
<button class='icon_button' name="admin_ident" value= "{{ account.identifier }}"
{% if acc_count == 1 %} disabled {% endif %}>
<span class="material-symbols-outlined">delete</span>
</button>
</form>
{% endfor %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion quafelweb/account_controller/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def manage_accounts(request: HttpRequest) -> HttpResponse:
if search := request.GET.get("search"):
accounts = [acc for acc in accounts if search in acc.identifier]

return render(request, "account.html", context={"accounts": accounts})
return render(request, "account.html", context={"accounts": accounts, "acc_count": accounts.count()})

@staticmethod
@require_login
Expand Down

0 comments on commit 6e81e2d

Please sign in to comment.