Browse Source

Component.new_rank() correction

En plus de modifié la valeur en base, modifie la valeur d'instance.
Driky 9 years ago
parent
commit
2e1fb44d26
1 changed files with 5 additions and 0 deletions
  1. 5
    0
      EditorialModel/components.py

+ 5
- 0
EditorialModel/components.py View File

@@ -182,6 +182,7 @@ class EmComponent(object):
182 182
                     c.execute(req, vals)
183 183
                     c.close()
184 184
 
185
+                    self.rank = new_rank
185 186
                 elif(sign == '+'):
186 187
                     req = req.where(getattr(component.c, self.ranked_in) == self.ranked_in and (component.c.rank <= self.rank + new_rank and component.c.rank > self.rank))
187 188
 
@@ -199,6 +200,8 @@ class EmComponent(object):
199 200
                     c.execute(req, vals)
200 201
                     c.close()
201 202
 
203
+                    self.rank += new_rank
204
+
202 205
                 elif(sign == '-'):
203 206
                     req = req.where(getattr(component.c, self.ranked_in) == self.ranked_in and (component.c.rank >= self.rank - new_rank and component.c.rank < self.rank))
204 207
 
@@ -215,6 +218,8 @@ class EmComponent(object):
215 218
                     req = component.update().where(component.c.uid == sql.bindparam('id')).values(rank = sql.bindparam('rank'))
216 219
                     c.execute(req, vals)
217 220
                     c.close()
221
+
222
+                    self.rank -= new_rank
218 223
                 else:
219 224
                     logger.error("Bad argument")
220 225
                     raise TypeError('Excepted a string (\'=\' or \'+\' or \'-\') not a '+str(type(new_rank)))

Loading…
Cancel
Save