fix lookup by id
This commit is contained in:
parent
80f2d02dcc
commit
4cabfd0476
2 changed files with 16 additions and 12 deletions
|
@ -247,16 +247,19 @@ def findMetadata(data):
|
||||||
elif key == 'id':
|
elif key == 'id':
|
||||||
import user.models
|
import user.models
|
||||||
items = {}
|
items = {}
|
||||||
for m in user.models.Metadata.query.filter_by(item_id=data[key]):
|
for u in user.models.User.query.filter_by(peered=True):
|
||||||
if m.data_hash not in items:
|
peer = utils.get_peer(u.id)
|
||||||
items[m.data_hash] = m.data
|
if data[key] in peer.library:
|
||||||
items[m.data_hash]['users'] = [m.user_id]
|
h = peer.get_metahash(data[key])
|
||||||
j = items[m.data_hash]
|
if h not in items:
|
||||||
|
items[h] = peer.library[data[key]].get('meta', {}).copy()
|
||||||
|
items[h]['users'] = [u.id]
|
||||||
|
j = items[h]
|
||||||
for key in [k['id'] for k in settings.config['itemKeys'] if isinstance(k['type'], list)]:
|
for key in [k['id'] for k in settings.config['itemKeys'] if isinstance(k['type'], list)]:
|
||||||
if key in j and not isinstance(j[key], list):
|
if key in j and not isinstance(j[key], list):
|
||||||
j[key] = [j[key]] if j[key] else []
|
j[key] = [j[key]] if j[key] else []
|
||||||
else:
|
else:
|
||||||
items[m.data_hash]['users'].append(m.user_id)
|
items[h]['users'].append(u.id)
|
||||||
response['items'] = list(items.values())
|
response['items'] = list(items.values())
|
||||||
return response
|
return response
|
||||||
actions.register(findMetadata)
|
actions.register(findMetadata)
|
||||||
|
|
|
@ -277,7 +277,8 @@ oml.ui.identifyDialog = function(data) {
|
||||||
$list = Ox.TableList({
|
$list = Ox.TableList({
|
||||||
columns: [{
|
columns: [{
|
||||||
format: function(value, data) {
|
format: function(value, data) {
|
||||||
return '<b>' + data.title + '</b> ' + data.author
|
return '<b>' + Ox.encodeHTMLEntities(data.title) + '</b> '
|
||||||
|
+ Ox.encodeHTMLEntities(data.author);
|
||||||
},
|
},
|
||||||
id: 'index',
|
id: 'index',
|
||||||
visible: true,
|
visible: true,
|
||||||
|
|
Loading…
Reference in a new issue