use peer.library for lists

This commit is contained in:
j 2016-02-11 21:58:46 +05:30
parent 9d7a553b95
commit b12e61c5b4

View file

@ -121,6 +121,28 @@ class User(db.Model):
def lists_json(self): def lists_json(self):
self.library 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_')] return [l.json() for l in self.lists.order_by('index_')]
def update_peering(self, peered, username=None): def update_peering(self, peered, username=None):