fix first user

This commit is contained in:
j 2016-04-04 23:19:17 +02:00
parent 55c1388e72
commit eb11424003

View file

@ -161,9 +161,13 @@ class User(db.Model):
if not was_peering: if not was_peering:
Changelog.record(state.user(), 'addpeer', self.id, self.nickname) Changelog.record(state.user(), 'addpeer', self.id, self.nickname)
if not 'index' in self.info: if not 'index' in self.info:
self.info['index'] = max([ qs = User.query.filter_by(peered=True)
u.info.get('index', -1) for u in User.query.filter_by(peered=True) if qs.count():
]) + 1 self.info['index'] = max([
u.info.get('index', -1) for u in qs
]) + 1
else:
self.info['index'] = 1
self.peered = True self.peered = True
self.save() self.save()
if self.id in state.removepeer: if self.id in state.removepeer: