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):