Parcourir la source

Merge pull request #11 from JocelynDelalande/validation_fixes

Validation fixes
JocelynDelalande il y a 10 ans
Parent
commit
e7b2b84531
1 fichiers modifiés avec 6 ajouts et 6 suppressions
  1. 6 6
      backend.py

+ 6 - 6
backend.py

@@ -155,14 +155,14 @@ def submit_wifi_form():
 
     if floor and not floor_total:
         errors.append((field_names['floor_total'], "ce champ est requis"))
-    elif not floor and floor_total:
+    if not floor and floor_total:
         errors.append((field_names['floor'], "ce champ est requis"))
-    elif floor and floor_total and (int(floor) > int(floor_total)):
+    if floor and floor_total and (int(floor) > int(floor_total)):
         errors.append((field_names['floor'], "Étage supérieur au nombre total"))
-    if (int(floor) < 0):
-         errors.append((field_names['floor'], "l'étage doit-être positif"))
-    if (int(floor_total) < 0):
-         errors.append((field_names['floor_total'], "le nombre d'étages doit-être positif"))
+    if floor and (int(floor) < 0):
+        errors.append((field_names['floor'], "l'étage doit-être positif"))
+    if floor_total and (int(floor_total) < 0):
+        errors.append((field_names['floor_total'], "le nombre d'étages doit-être positif"))
 
     if errors:
         return template('wifi-form', errors=errors, data=request.forms,