Browse Source

EmComponent: get_max_rank() should return an int

ArnAud 9 years ago
parent
commit
5fb9c8b7b6
2 changed files with 3 additions and 2 deletions
  1. 1
    1
      EditorialModel/components.py
  2. 2
    1
      EditorialModel/model.py

+ 1
- 1
EditorialModel/components.py View File

@@ -116,7 +116,7 @@ class EmComponent(object):
116 116
     # @return A positive integer or -1 if no components
117 117
     def get_max_rank(self):
118 118
         components = self.same_rank_group()
119
-        return 1 if len(components) == 0 else components[-1].rank
119
+        return len(components) + 1
120 120
 
121 121
     ## Return an array of instances that are concerned by the same rank
122 122
     # @return An array of instances that are concerned by the same rank

+ 2
- 1
EditorialModel/model.py View File

@@ -141,10 +141,11 @@ class Model(object):
141 141
         datas['uid'] = self.new_uid()
142 142
         em_component = em_obj(self, **datas)
143 143
 
144
+        em_component.rank = em_component.get_max_rank()
145
+
144 146
         self._components['uids'][em_component.uid] = em_component
145 147
         self._components[self.name_from_emclass(em_component.__class__)].append(em_component)
146 148
 
147
-        em_component.rank = em_component.get_max_rank()
148 149
         if rank != 'last':
149 150
             em_component.set_rank(1 if rank == 'first' else rank)
150 151
 

Loading…
Cancel
Save