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
                     c.execute(req, vals)
182
                     c.execute(req, vals)
183
                     c.close()
183
                     c.close()
184
 
184
 
185
+                    self.rank = new_rank
185
                 elif(sign == '+'):
186
                 elif(sign == '+'):
186
                     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
                     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
                     c.execute(req, vals)
200
                     c.execute(req, vals)
200
                     c.close()
201
                     c.close()
201
 
202
 
203
+                    self.rank += new_rank
204
+
202
                 elif(sign == '-'):
205
                 elif(sign == '-'):
203
                     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))
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
                     req = component.update().where(component.c.uid == sql.bindparam('id')).values(rank = sql.bindparam('rank'))
218
                     req = component.update().where(component.c.uid == sql.bindparam('id')).values(rank = sql.bindparam('rank'))
216
                     c.execute(req, vals)
219
                     c.execute(req, vals)
217
                     c.close()
220
                     c.close()
221
+
222
+                    self.rank -= new_rank
218
                 else:
223
                 else:
219
                     logger.error("Bad argument")
224
                     logger.error("Bad argument")
220
                     raise TypeError('Excepted a string (\'=\' or \'+\' or \'-\') not a '+str(type(new_rank)))
225
                     raise TypeError('Excepted a string (\'=\' or \'+\' or \'-\') not a '+str(type(new_rank)))

Loading…
Cancel
Save