Skip to content

Commit

Permalink
records: implement collaborations name autocomplete
Browse files Browse the repository at this point in the history
Signed-off-by: Iuliana Voinea <[email protected]>
  • Loading branch information
Iuliana Voinea committed Nov 28, 2017
1 parent 3f2599f commit a9f84e4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion inspirehep/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@
field='bookautocomplete'
)),
collaboration_name=dict(completion=dict(
field='collaboration_suggest'
field='collaborations.collaboration_suggest'
))
),
list_route='/literature/',
Expand Down
7 changes: 3 additions & 4 deletions inspirehep/modules/records/mappings/records/hep.json
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,13 @@
},
"value": {
"type": "string"
},
"collaboration_suggest": {
"type": "completion"
}
},
"type": "object"
},
"collaboration_suggest": {
"payloads": true,
"type": "completion"
},
"control_number": {
"type": "integer"
},
Expand Down
24 changes: 11 additions & 13 deletions inspirehep/modules/records/receivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,17 @@ def populate_collaboration_suggest(sender, json, *args, **kwargs):
if 'hep.json' not in json.get('$schema'):
return

names = force_list(get_value(json, 'collaborations.value', default=[]))
recids = force_list(get_value(json, 'collaborations.recid', default=[]))

input_values = [el for el in chain(names, recids) if el]

json.update({
'collaboration_suggest': {
'input': input_values,
'payload': {
'collaborations': names
},
},
})
collaborations = json.get('collaborations', [])

for collaboration in collaborations:
name = collaboration.get('value')
if name:
collaboration.update({
'collaboration_suggest': {
'input': name,
'output': name,
},
})


def populate_inspire_document_type(sender, json, *args, **kwargs):
Expand Down

0 comments on commit a9f84e4

Please sign in to comment.