From b12e61c5b49094f8b25c44f6fe7e49d6036d6266 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 11 Feb 2016 21:58:46 +0530 Subject: [PATCH] use peer.library for lists --- oml/user/models.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/oml/user/models.py b/oml/user/models.py index a503933..eee1c87 100644 --- a/oml/user/models.py +++ b/oml/user/models.py @@ -121,6 +121,28 @@ class User(db.Model): def lists_json(self): self.library + if self.id != settings.USER_ID: + peer = utils.get_peer(self.id) + lists = [] + lists.append({ + 'id': self.nickname + ':', + 'user': self.name, + 'items': len(peer.library), + 'name': 'Library', + 'type': 'library' + }) + index = 0 + for name in peer.info['listorder']: + lists.append({ + 'id': '%s:%s' % (self.nickname, name), + 'user': self.name, + 'name': name, + 'index': index, + 'items': len(peer.info['lists'].get(name, [])), + 'type': 'static' + }) + index += 1 + return lists return [l.json() for l in self.lists.order_by('index_')] def update_peering(self, peered, username=None):