Skip to content

Commit

Permalink
Admins now can't delete themselves
Browse files Browse the repository at this point in the history
  • Loading branch information
juliushaag committed Aug 13, 2024
1 parent 6e81e2d commit f61df43
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
9 changes: 4 additions & 5 deletions quafelweb/account_controller/templates/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{% block content %}
<div class="page_panel">
<form action="/account" method="get" id='account_search'>
<input type="text" name='search' value={{request.GET.search}}>
<input type="text" name='search' value="{{request.GET.search}}">
<span>Search</span>
<button type="submit"><span class="material-symbols-outlined">search</span></button>
</form>
Expand All @@ -17,10 +17,9 @@
<form action="delete/" class='account_entry' method='post'>
{% csrf_token %}
<p>{{ account.identifier }}</p>
<button class='icon_button' name="admin_ident" value= "{{ account.identifier }}"
{% if acc_count == 1 %} disabled {% endif %}>
<span class="material-symbols-outlined">delete</span>
</button>
{% if request.session.admin_ident != account.identifier %}
<button class='icon_button' name="admin_ident" value="{{account.identifier}}"><span class="material-symbols-outlined">delete</span></button>
{% endif %}
</form>
{% endfor %}
</div>
Expand Down
7 changes: 5 additions & 2 deletions quafelweb/account_controller/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ def add_admin(request) -> HttpResponse:
@staticmethod
@require_login
def remove_admin(request) -> HttpResponse:

if ident := request.POST.get("admin_ident"):

ident = request.POST.get("admin_ident")
print(AdminAccount.objects.all(), ident)
if ident and ident != AccountView.get_identifier(request):
AdminAccount.objects.get(identifier=ident).delete()

return redirect(reverse("account"))
Expand Down Expand Up @@ -107,6 +109,7 @@ def denied(request: HttpRequest):
"info_type": "error",
"header": "No Access",
"message": "You dont have access to this resource",
"url_link" : "index"
}
return render(request, "info.html", context=context)

Expand Down
2 changes: 1 addition & 1 deletion quafelweb/hardware_controller/templates/hardware.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{%for hardware in profiles %}
<form class='hardware_entry' action="configure/" method="get">
<p>{{ hardware.name }}</p>
<button class="icon_button" name="id" value={{hardware.uuid}}><span class="material-symbols-outlined">edit</span></button>
<button class="icon_button" name="id" value="{{hardware.uuid}}"><span class="material-symbols-outlined">edit</span></button>
</form>
{% empty %}
<p id="no_profiles">No hardware profiles found</p>
Expand Down
20 changes: 10 additions & 10 deletions quafelweb/simulation_controller/templates/simulation.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
<h4>Qubits</h4>
<div class="selection_group">
<div>
<input name="qubits_min" type='number' value={{qubits_min}}>
<input name="qubits_min" type='number' value="{{qubits_min}}">
<span>From</span>
</div>
<div>
<input name="qubits_max" type='number' value={{qubits_max}}>
<input name="qubits_max" type='number' value="{{qubits_max}}">
<span>To</span>
</div>
</div>
<div class="selection_group">
<div>
<input name="qubits_increment" type='number' value={{qubits_increment}}>
<input name="qubits_increment" type='number' value="{{qubits_increment}}">
<span>Increment</span>
</div>
<div>
Expand All @@ -45,17 +45,17 @@ <h4>Qubits</h4>
<h4>Depth</h4>
<div class="selection_group">
<div>
<input name="depth_min" type='number' value={{depth_min}}>
<input name="depth_min" type='number' value="{{depth_min}}">
<span>From</span>
</div>
<div>
<input name="depth_max" type='number' value={{depth_max}}>
<input name="depth_max" type='number' value="{{depth_max}}">
<span>To</span>
</div>
</div>
<div class="selection_group">
<div>
<input name="depth_increment" type='number' value={{depth_increment}}>
<input name="depth_increment" type='number' value="{{depth_increment}}">
<span for="depth_increment">Increment</span>
</div>
<div>
Expand All @@ -74,17 +74,17 @@ <h4>Depth</h4>
<h4>Shots</h4>
<div class="selection_group">
<div>
<input name="shots_min" type='number' value={{shots_min}}>
<input name="shots_min" type='number' value="{{shots_min}}">
<span>From</span>
</div>
<div>
<input name="shots_max" type='number' value={{shots_max}}>
<input name="shots_max" type='number' value="{{shots_max}}">
<span>To</span>
</div>
</div>
<div class="selection_group">
<div>
<input name="shots_increment" type='number' value={{shots_increment}}></input>
<input name="shots_increment" type='number' value="{{shots_increment}}"></input>
<span>Increment</span>
</div>
<div>
Expand Down Expand Up @@ -132,7 +132,7 @@ <h4>Shots</h4>
<div id="env_container">
{% for env in envs %}
<div class="env_entry">
<input type="checkbox" name={{ env.3 }} {% if env.4 %}checked{% endif %}></button>
<input type="checkbox" name="{{ env.3 }}" {% if env.4 %}checked{% endif %}></button>
<p>{{env.0.name}}</p>
<p>{{env.1.name}}</p>
</div>
Expand Down

0 comments on commit f61df43

Please sign in to comment.