Skip to content
Snippets Groups Projects
Commit f7a36737 authored by jr4234s's avatar jr4234s
Browse files

Some error fixes with the validation.

parent 2c6aef97
No related branches found
No related tags found
No related merge requests found
Showing
with 9 additions and 6 deletions
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -500,8 +500,9 @@ function getNetworkSettings() {
return parameters;
}
function sendDataToBackend() {
async function sendDataToBackend() {
let parameters = getNetworkSettings();
console.log(parameters);
const fetchOption = {
method: "POST",
credentials: "same-origin",
......@@ -512,7 +513,7 @@ function sendDataToBackend() {
},
body: JSON.stringify(parameters),
}
return fetch("/interface/network_settings/set/", fetchOption)
return await fetch("/interface/network_settings/set/", fetchOption)
.then(res => {
if (res.ok) {
return res.text();
......@@ -528,7 +529,7 @@ function sendDataToBackend() {
console.log("data");
return false;
} else if (res === "corrupt_params") {
console.log("data");
console.log("params");
return false;
} else {
console.log("Request_failure");
......@@ -538,8 +539,8 @@ function sendDataToBackend() {
}
/* 8. Perform Simulation */
function initSimulation() {
let result = sendDataToBackend();
async function initSimulation() {
let result = await sendDataToBackend();
if (result) {
clickStart();
startSimulation()
......
......
......@@ -3,9 +3,11 @@ from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _
def validate_number(number):
if not number:
raise ValidationError(_("Number should not be empty!"), params={"number": number},)
try:
num = float(number)
except ValueError as ex:
except ValueError:
raise ValidationError(_('%(number)s is not an valid parameter'), params={"number": number},)
......
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment