Browse Source

[#44] Ajout d'un début de méthode check et appel de celle-ci dans le delete

Roland Haroutiounian 9 years ago
parent
commit
b668556c3f
2 changed files with 20 additions and 2 deletions
  1. 10
    1
      EditorialModel/fieldgroups.py
  2. 10
    1
      EditorialModel/fields.py

+ 10
- 1
EditorialModel/fieldgroups.py View File

@@ -16,6 +16,12 @@ class EmFieldGroup(EmComponent):
16 16
     ## List of fields
17 17
     _fields = [('class_id', ftypes.EmField_integer)]
18 18
 
19
+    ## Check if the EmFieldGroup is valid
20
+    # @return True if valid False if not
21
+    def check(self):
22
+        super(EmFieldGroup, self).check()
23
+        return True
24
+
19 25
     ## Deletes a fieldgroup
20 26
     # @return True if the deletion is a success, False if not
21 27
     def delete(self):
@@ -24,7 +30,10 @@ class EmFieldGroup(EmComponent):
24 30
         if len(fieldgroup_fields) > 0:
25 31
             raise NotEmptyError("This Fieldgroup still contains fields. It can't be deleted then")
26 32
         # then we delete this fieldgroup
27
-        return self.model.delete_component(self.uid)
33
+        if self.model.delete_component(self.uid):
34
+            return self.check()
35
+        else:
36
+            return False
28 37
 
29 38
     ## Get the list of associated fields
30 39
     # if type_id, the fields will be filtered to represent selected fields of this EmType

+ 10
- 1
EditorialModel/fields.py View File

@@ -24,8 +24,17 @@ class EmField(EmComponent):
24 24
     def __init__(self, datas, model):
25 25
         super(EmField, self).__init__(datas, model)
26 26
 
27
+    ## Check if the EmField is valid
28
+    # @return True if valid False if not
29
+    def check(self):
30
+        super(EmField, self).check()
31
+        return True
32
+
27 33
     ## @brief Delete a field if it's not linked
28 34
     # @return bool : True if deleted False if deletion aborded
29 35
     # @todo Check if unconditionnal deletion is correct
30 36
     def delete(self):
31
-        return self.model.delete_component(self.uid)
37
+        if self.model.delete_component(self.uid):
38
+            return self.check()
39
+        else:
40
+            return False

Loading…
Cancel
Save