From eb11424003fd2ce1cf2750ce0740ffe884343df6 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 4 Apr 2016 23:19:17 +0200 Subject: [PATCH] fix first user --- oml/user/models.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/oml/user/models.py b/oml/user/models.py index 82da47e..e0b2a82 100644 --- a/oml/user/models.py +++ b/oml/user/models.py @@ -161,9 +161,13 @@ class User(db.Model): if not was_peering: Changelog.record(state.user(), 'addpeer', self.id, self.nickname) if not 'index' in self.info: - self.info['index'] = max([ - u.info.get('index', -1) for u in User.query.filter_by(peered=True) - ]) + 1 + qs = User.query.filter_by(peered=True) + if qs.count(): + self.info['index'] = max([ + u.info.get('index', -1) for u in qs + ]) + 1 + else: + self.info['index'] = 1 self.peered = True self.save() if self.id in state.removepeer: