not in
This commit is contained in:
parent
3e5c3c9a47
commit
abc0b82961
4 changed files with 48 additions and 47 deletions
|
|
@ -33,7 +33,7 @@ class User(db.Model):
|
|||
|
||||
nickname = sa.Column(sa.String(256), unique=True)
|
||||
|
||||
pending = sa.Column(sa.String(64)) # sent|received
|
||||
pending = sa.Column(sa.String(64)) # sent|received
|
||||
queued = sa.Column(sa.Boolean())
|
||||
peered = sa.Column(sa.Boolean())
|
||||
online = sa.Column(sa.Boolean())
|
||||
|
|
@ -160,7 +160,7 @@ class User(db.Model):
|
|||
self.save()
|
||||
if not was_peering:
|
||||
Changelog.record(state.user(), 'addpeer', self.id, self.nickname)
|
||||
if not 'index' in self.info:
|
||||
if 'index' not in self.info:
|
||||
self.info['index'] = max([
|
||||
u.info.get('index', -1) for u in User.query.filter_by(peered=True)
|
||||
] + [0]) + 1
|
||||
|
|
@ -204,7 +204,7 @@ class User(db.Model):
|
|||
name = self.info.get('nickname') or self.info.get('username') or 'anonymous'
|
||||
nickname = name
|
||||
n = 2
|
||||
while self.query.filter_by(nickname=nickname).filter(User.id!=self.id).first():
|
||||
while self.query.filter_by(nickname=nickname).filter(User.id != self.id).first():
|
||||
nickname = '%s [%d]' % (name, n)
|
||||
n += 1
|
||||
self.nickname = nickname
|
||||
|
|
@ -237,9 +237,8 @@ class User(db.Model):
|
|||
state.db.session.commit()
|
||||
|
||||
list_items = sa.Table('listitem', db.metadata,
|
||||
sa.Column('list_id', sa.Integer(), sa.ForeignKey('list.id')),
|
||||
sa.Column('item_id', sa.String(32), sa.ForeignKey('item.id'))
|
||||
)
|
||||
sa.Column('list_id', sa.Integer(), sa.ForeignKey('list.id')),
|
||||
sa.Column('item_id', sa.String(32), sa.ForeignKey('item.id')))
|
||||
|
||||
class List(db.Model):
|
||||
__tablename__ = 'list'
|
||||
|
|
@ -255,7 +254,7 @@ class List(db.Model):
|
|||
user = sa.orm.relationship('User', backref=sa.orm.backref('lists', lazy='dynamic'))
|
||||
|
||||
items = sa.orm.relationship('Item', secondary=list_items,
|
||||
backref=sa.orm.backref('lists', lazy='dynamic'))
|
||||
backref=sa.orm.backref('lists', lazy='dynamic'))
|
||||
|
||||
@classmethod
|
||||
def get(cls, user_id, name=None):
|
||||
|
|
@ -305,13 +304,13 @@ class List(db.Model):
|
|||
|
||||
@classmethod
|
||||
def rename_user(cls, old, new):
|
||||
for l in cls.query.filter(cls._query!=None):
|
||||
for l in cls.query.filter(cls._query is not None):
|
||||
|
||||
def update_conditions(conditions):
|
||||
changed = False
|
||||
for c in conditions:
|
||||
if 'conditions' in c:
|
||||
changed = update_conditions(c['conditions'] )
|
||||
changed = update_conditions(c['conditions'])
|
||||
else:
|
||||
if c.get('key') == 'list' and c.get('value', '').startswith('%s:' % old):
|
||||
c['value'] = '%s:%s' % new, c['value'].split(':', 1)[1]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue