|
@@ -158,23 +158,23 @@ class EmComponent(object):
|
158
|
158
|
# @param sign str: Un charactère qui peut être : '=' pour afecter un rank, '+' pour ajouter le modificateur de rank ou '-' pour soustraire le modificateur de rank.
|
159
|
159
|
#
|
160
|
160
|
# @return bool: True en cas de réussite False en cas d'echec.
|
161
|
|
- def modify_rank(self, new_rank, sign):
|
|
161
|
+ def modify_rank(self, new_rank, sign = '='):
|
162
|
162
|
if(type(new_rank) is int):
|
163
|
163
|
if(new_rank >= 0):
|
164
|
164
|
dbe = self.__class__.getDbE()
|
165
|
165
|
component = sql.Table(self.table, sqlutils.meta(dbe))
|
166
|
166
|
req = sql.sql.select([component.c.uid, component.c.rank])
|
167
|
167
|
if(sign == '='):
|
168
|
|
- req = req.where(getattr(component.c, self.ranked_in) == self.ranked_in and component.c.rank == new_rank)
|
|
168
|
+ req = req.where(getattr(component.c, self.ranked_in) == getattr(self, self.ranked_in) and component.c.rank == new_rank)
|
169
|
169
|
c = dbe.connect()
|
170
|
170
|
res = c.execute(req)
|
171
|
171
|
res = res.fetchone()
|
172
|
172
|
c.close()
|
173
|
173
|
if(res != None):
|
174
|
174
|
if(new_rank < self.rank):
|
175
|
|
- req = req.where(getattr(component.c, self.ranked_in) == self.ranked_in and (component.c.rank >= new_rank))
|
|
175
|
+ req = req.where(getattr(component.c, self.ranked_in) == getattr(self, self.ranked_in) and (component.c.rank >= new_rank))
|
176
|
176
|
else:
|
177
|
|
- req = req.where(getattr(component.c, self.ranked_in) == self.ranked_in and (component.c.rank <= new_rank ))
|
|
177
|
+ req = req.where(getattr(component.c, self.ranked_in) == getattr(self, self.ranked_in) and (component.c.rank <= new_rank ))
|
178
|
178
|
|
179
|
179
|
c = dbe.connect()
|
180
|
180
|
res = c.execute(req)
|
|
@@ -201,7 +201,7 @@ class EmComponent(object):
|
201
|
201
|
raise ValueError('new_rank to big, new_rank - 1 doesn\'t exist. new_rank = '+str((new_rank)))
|
202
|
202
|
elif(sign == '+'):
|
203
|
203
|
if(new_rank != 0):
|
204
|
|
- 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
|
+ req = req.where(getattr(component.c, self.ranked_in) == getattr(self, self.ranked_in) and (component.c.rank <= self.rank + new_rank and component.c.rank > self.rank))
|
205
|
205
|
|
206
|
206
|
c = dbe.connect()
|
207
|
207
|
res = c.execute(req)
|
|
@@ -223,7 +223,7 @@ class EmComponent(object):
|
223
|
223
|
raise ValueError('Excepted a positive int not a null. new_rank = '+str((new_rank)))
|
224
|
224
|
elif(sign == '-'):
|
225
|
225
|
if(new_rank != 0):
|
226
|
|
- 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))
|
|
226
|
+ req = req.where(getattr(component.c, self.ranked_in) == getattr(self, self.ranked_in) and (component.c.rank >= self.rank - new_rank and component.c.rank < self.rank))
|
227
|
227
|
|
228
|
228
|
c = dbe.connect()
|
229
|
229
|
res = c.execute(req)
|