|
|
@@ -1,5 +1,7 @@
|
|
|
'''
|
|
|
|
|
|
+ Extend the cerberus library with more validation methods and french translations
|
|
|
+
|
|
|
@author: olivier.massot, 2018
|
|
|
'''
|
|
|
from datetime import datetime
|
|
|
@@ -79,31 +81,6 @@ class ExtendedValidator(cerberus.validator.Validator):
|
|
|
else:
|
|
|
self._error(field, "Valeur non-autorisée: {}".format(item))
|
|
|
|
|
|
-class GeoValidator(ExtendedValidator):
|
|
|
-
|
|
|
- def _validate_inside_box(self, bounding_box, field, value):
|
|
|
- """ Contrôle l'inclusion de la bounding box de l'entité dans la box donneé
|
|
|
-
|
|
|
- The rule's arguments are validated against this schema:
|
|
|
- {'type': 'list'}
|
|
|
- """
|
|
|
-# geom_type, bounding_box = geom
|
|
|
-#
|
|
|
-# if value.geom_type != geom_type:
|
|
|
-# self._error(field, "Le type de géométrie est {} (attendu: {})".format(value.geom_name, gis_.GEOM_NAMES[geom_type]))
|
|
|
-
|
|
|
- xmin, ymin, xmax, ymax = bounding_box
|
|
|
-
|
|
|
- try:
|
|
|
- x1, y1, x2, y2 = value.bounding_box
|
|
|
-
|
|
|
- if any(x < xmin or x > xmax for x in (x1, x2)) or \
|
|
|
- any(y < ymin or y > ymax for y in (y1, y2)):
|
|
|
- self._error(field, "Certaines coordonnées hors de l'emprise autorisée")
|
|
|
- except AttributeError:
|
|
|
- pass
|
|
|
-
|
|
|
-
|
|
|
def _translate_messages(message):
|
|
|
message = message.replace("string", "texte")
|
|
|
message = message.replace("integer", "nombre entier")
|