Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
nils-prommersberger committed Sep 19, 2024
2 parents 0da5d46 + bf6926a commit 2a7ac6d
Show file tree
Hide file tree
Showing 20 changed files with 439 additions and 306 deletions.
15 changes: 13 additions & 2 deletions quafelweb/account_controller/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def setUp(self):
self.client = Client()

self.account_url = reverse('account')
self.add_url = reverse('add')
self.delete_url = reverse('delete')
self.add_url = reverse('add_account')
self.delete_url = reverse('delete_account')

self.account1 = AdminAccount.objects.create(identifier='admin1')
def test_manage_accounts_GET(self):
Expand Down Expand Up @@ -67,4 +67,15 @@ def test_remove_accounts_POST_no_data(self):
self.assertEquals(response.status_code, 302)
self.assertEquals(new_count, initial_count)

def test_accounts_is_logged_in(self):

initial_count = AdminAccount.objects.count()

response = self.client.post(self.delete_url)

new_count = AdminAccount.objects.count()

self.assertEquals(response.status_code, 302)
self.assertEquals(new_count, initial_count)


4 changes: 2 additions & 2 deletions quafelweb/account_controller/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

urlpatterns = [
path("", views.AccountView.manage_accounts, name="account"),
path("add/", views.AccountView.add_admin, name="add"),
path("delete/", views.AccountView.remove_admin, name="delete"),
path("add/", views.AccountView.add_admin, name="add_account"),
path("delete/", views.AccountView.remove_admin, name="delete_account"),
path("login/", views.AccountView.authenticate, name="login"),
path("logout/", views.AccountView.logout, name="logout"),
path("auth/", views.AccountView.authenticate_callback, name="auth_callback"),
Expand Down
2 changes: 1 addition & 1 deletion quafelweb/hardware_controller/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

urlpatterns = [
path("", views.HardwareView.manage_profiles, name="hardware"),
path("add/", views.HardwareView.add_profile),
path("add/", views.HardwareView.add_profile, name="add_hardware"),
path("delete/", views.HardwareView.delete_profile, name="delete_hardware"),
path("delete_confirm/", views.HardwareView.delete_runs, name="delete_confirm"),
path("configure/", views.HardwareView.configure_profile, name="configure_hardware"),
Expand Down
3 changes: 2 additions & 1 deletion quafelweb/quafel_simulators/quafelsubmitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from quafel_simulators.base.simulation_request import QuafelSimulationRequest
from quafel_simulators.output import QuafelOutputHardware
from quafel_simulators.util.connection import SubmitConnection, OutputConnection
from simulation_controller.util.simulation_request import SimulationRequest


class QuafelSubmissionState(Enum):
Expand Down Expand Up @@ -120,7 +121,7 @@ def _submit(self, simulation_request: QuafelSimulationRequest, handle: Callable[
if handle is not None:
handle(simulation_request)

def submit(self, simulation_request: QuafelSimulationRequest, handle: Callable[[QuafelSimulationRequest], None] = None) -> bool:
def submit(self, simulation_request: QuafelSimulationRequest, handle: Callable[[SimulationRequest], None] = None) -> bool:
"""
Submit a simulation request
:param simulation_request: The simulation request to submit
Expand Down
1 change: 1 addition & 0 deletions quafelweb/quafelweb/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"simulation_controller.file_checker.FileCheckerMiddleware"
]

ROOT_URLCONF = "quafelweb.urls"
Expand Down
14 changes: 14 additions & 0 deletions quafelweb/simulation_controller/file_checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


from typing import Any


class FileCheckerMiddleware:

def __init__(self, get_response) -> None:
self.get_response = get_response

def __call__(self, request) -> Any:
response = self.get_response(request)
print("CALLED MIDDLE WARE")
return response
2 changes: 1 addition & 1 deletion quafelweb/simulation_controller/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ class SimulationRequest(models.Model):

requested_runs = models.ForeignKey(
SimulationRun, on_delete=models.CASCADE, max_length=1000
) # yeah idk
)

user = models.CharField(max_length=40)
33 changes: 8 additions & 25 deletions quafelweb/simulation_controller/static/simulation.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,8 @@

/* Confirmation page */

#confirmation_page {
position: absolute;
top: -1em;
left: 0;
width: 100%;
height: 100%;
}

#confirmation_veil {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
backdrop-filter: blur(5px);
}

#confirmation_content {
position: relative;
left: 15%;
width: 70%;
height: 90%;
border: 1px black solid;
background-color: white;
padding: 2em;
box-sizing: border-box;
Expand Down Expand Up @@ -120,7 +99,7 @@
flex-direction: column;
overflow: auto;
width: 40em;
height: 100%;
height: 20em;
}

.env_conf_entry {
Expand All @@ -146,19 +125,23 @@
#conf_hardware_container {
display: flex;
flex-direction: column;
max-height: 100%;
height: 30em;
overflow: auto;
}

.hardware_entry {
display: flex;
flex-direction: column;
margin: 0 2em 1em 2em;
margin-bottom: 1em;
}

.hardware_entry > div {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
text-align: left;
gap: 1em;
}
}

#confirmation_button {
width: 15em;
}
106 changes: 106 additions & 0 deletions quafelweb/simulation_controller/templates/confirmation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{% extends "core.html" %}


{% block head %}
{% load static %}
<link rel="stylesheet" href="{% static 'simulation.css' %}">
{% endblock%}

{% block content %}
<form id="form_content" method="post">

{% for key, value in request.POST.items %}
<input type="hidden" name="{{key}}" value="{{value}}">
{% endfor %}
<div class="page_panel">
<div id="confirmation_content">
<h2>Overview</h2>
<div id="conf_content">

<div id="conf_overview">
<div id="conf_upper_part">
<div>
<div></div>
<div><b>Start</b></div>
<div><b>End</b></div>
<div><b>Increment</b></div>
<div><b>Type</b></div>
<div><b>Total</b></div>
</div>
<div>
<div><b>Qubits</b></div>
<div>{{qubits_min}}</div>
<div>{{qubits_max}}</div>
<div>{{qubits_increment}}</div>
<div>{{qubits_increment_type}}</div>

<div>{{qubits_values|length}}</div>
</div>
<div>
<div><b>Depth</b></div>
<div>{{depth_min}}</div>
<div>{{depth_max}}</div>
<div>{{depth_increment}}</div>
<div>{{depth_increment_type}}</div>

<div>{{depth_values|length}}</div>
</div>
<div>
<div><b>Shots</b></div>
<div>{{shots_min}}</div>
<div>{{shots_max}}</div>
<div>{{shots_increment}}</div>
<div>{{shots_increment_type}}</div>

<div>{{shots_values|length}}</div>
</div>
<h3>Runs per environment: {{max_amount}}</h3>
</div>
<div id="conf_environments_container">
{% for env in selected_envs %}
<div class="env_conf_entry">
<p>{{env.0.name}}</p>
<p>{{env.1.name}}</p>
<p >{{env.2}}/{{max_amount}}</p>
</div>
{% endfor %}
</div>
<button formaction="{% url "simulation_configuration" %}">Back</button>
</div>
</div>
</div>
</div>
<div class="page_panel">
<div id="hardware_info">
<h3>Hardware authentication</h3>
<div id="conf_hardware_container">
{% for hardware in selected_hardware %}
<div class="hardware_entry">
<div>
<p><b>{{hardware.name}}</b> {{hardware.ip_addr}}</p>
</div>
<div>
<div>
<input name="NAME::{{hardware.name}}">
<span>Username</span>
</div>
<div>
<input type="password" name="PASSWORD::{{hardware.name}}">
<span>Password</span>
</div>
{% if hardware.needs_totp %}
<div>
<input name="TOTP::{{hardware.uuid}}">
<span>TOTP</span>
</div>
{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>
<button id="confirmation_button" formaction="{% url "submit" %}">Submit</button>
</div>
</div>
</form>
{% endblock %}
Loading

0 comments on commit 2a7ac6d

Please sign in to comment.