1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2026-06-13 22:20:47 +02:00

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

This commit is contained in:
Roland Haroutiounian 2015-07-24 11:12:21 +02:00
commit b668556c3f
2 changed files with 20 additions and 2 deletions

View file

@ -16,6 +16,12 @@ class EmFieldGroup(EmComponent):
## List of fields ## List of fields
_fields = [('class_id', ftypes.EmField_integer)] _fields = [('class_id', ftypes.EmField_integer)]
## Check if the EmFieldGroup is valid
# @return True if valid False if not
def check(self):
super(EmFieldGroup, self).check()
return True
## Deletes a fieldgroup ## Deletes a fieldgroup
# @return True if the deletion is a success, False if not # @return True if the deletion is a success, False if not
def delete(self): def delete(self):
@ -24,7 +30,10 @@ class EmFieldGroup(EmComponent):
if len(fieldgroup_fields) > 0: if len(fieldgroup_fields) > 0:
raise NotEmptyError("This Fieldgroup still contains fields. It can't be deleted then") raise NotEmptyError("This Fieldgroup still contains fields. It can't be deleted then")
# then we delete this fieldgroup # then we delete this fieldgroup
return self.model.delete_component(self.uid) if self.model.delete_component(self.uid):
return self.check()
else:
return False
## Get the list of associated fields ## Get the list of associated fields
# if type_id, the fields will be filtered to represent selected fields of this EmType # if type_id, the fields will be filtered to represent selected fields of this EmType

View file

@ -24,8 +24,17 @@ class EmField(EmComponent):
def __init__(self, datas, model): def __init__(self, datas, model):
super(EmField, self).__init__(datas, model) super(EmField, self).__init__(datas, model)
## Check if the EmField is valid
# @return True if valid False if not
def check(self):
super(EmField, self).check()
return True
## @brief Delete a field if it's not linked ## @brief Delete a field if it's not linked
# @return bool : True if deleted False if deletion aborded # @return bool : True if deleted False if deletion aborded
# @todo Check if unconditionnal deletion is correct # @todo Check if unconditionnal deletion is correct
def delete(self): def delete(self):
return self.model.delete_component(self.uid) if self.model.delete_component(self.uid):
return self.check()
else:
return False