Explorar el Código

Added the management of allowed_classes in Reference

Roland Haroutiounian hace 8 años
padre
commit
1c1d353719
Se han modificado 1 ficheros con 4 adiciones y 1 borrados
  1. 4
    1
      lodel/leapi/datahandlers/reference.py

+ 4
- 1
lodel/leapi/datahandlers/reference.py Ver fichero

@@ -20,7 +20,7 @@ class Reference(FieldDataHandler):
20 20
     ## @brief checks if the data value is valid
21 21
     # @param value
22 22
     # @return
23
-    def check_data_value(self, value):
23
+    def _check_data_value(self, value):
24 24
 
25 25
         if not isinstance(value, self._refs_class):
26 26
             return value, "The reference should be an instance of %s, %s gotten" % (self._refs_class, value.__class__)
@@ -35,4 +35,7 @@ class Reference(FieldDataHandler):
35 35
             if not isinstance(related, EmClass):
36 36
                 return value, "The reference %s should be an instance of EmClass, %s gotten" % (related.display_name,
37 37
                                                                                                 related.__class__)
38
+            if self.allowed_classes is not None and related.__class__.display_name not in self.allowed_classes:
39
+                return value, "The reference %s should be an instance of either one of those classes : %s, %s gotten" % \
40
+                              (related.display_name, self.allowed_classes, related.__class__)
38 41
         return value, None

Loading…
Cancelar
Guardar