mirror of
https://github.com/yweber/lodel2.git
synced 2025-10-21 08:39:03 +02:00
Solved a bug about checking ranks and getting max rank
This commit is contained in:
parent
46dfe3a7ba
commit
17c1eba918
2 changed files with 3 additions and 4 deletions
|
@ -113,7 +113,7 @@ class EmComponent(object):
|
|||
# @throw EmComponentCheckError if fails
|
||||
def check(self):
|
||||
self.model.sort_components(self.__class__)
|
||||
if self.get_max_rank() > len(self.same_rank_group()) or self.rank <= 0:
|
||||
if self.get_max_rank() != len(self.same_rank_group()) or self.rank <= 0:
|
||||
#Non continuous ranks
|
||||
for i, component in enumerate(self.same_rank_group()):
|
||||
component.rank = i + 1
|
||||
|
@ -127,8 +127,7 @@ class EmComponent(object):
|
|||
## @brief Get the maximum rank given an EmComponent child class and a ranked_in filter
|
||||
# @return A positive integer or -1 if no components
|
||||
def get_max_rank(self):
|
||||
components = self.same_rank_group()
|
||||
return len(components) + 1
|
||||
return len(self.same_rank_group())
|
||||
|
||||
## Return an array of instances that are concerned by the same rank
|
||||
# @return An array of instances that are concerned by the same rank
|
||||
|
|
|
@ -141,7 +141,7 @@ class Model(object):
|
|||
datas['uid'] = self.new_uid()
|
||||
em_component = em_obj(self, **datas)
|
||||
|
||||
em_component.rank = em_component.get_max_rank()
|
||||
em_component.rank = em_component.get_max_rank() + 1 #Inserting last by default
|
||||
|
||||
self._components['uids'][em_component.uid] = em_component
|
||||
self._components[self.name_from_emclass(em_component.__class__)].append(em_component)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue