Skip to content

Commit

Permalink
Improve the author autocompletion and ammend conference acceptnace test
Browse files Browse the repository at this point in the history
Signed-off-by: Iuliana Voinea <[email protected]>
  • Loading branch information
Iuliana Voinea committed Jan 31, 2018
1 parent c14fded commit 3afcd77
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ define([
this.dataEngine = new Bloodhound({
name: 'affiliations',
remote: {
url: '/api/institutions/_suggest?affiliation:%QUERY',
url: '/api/institutions/_suggest?affiliation=%QUERY',
filter: function(response) {
return $.map(response.affiliation[0].options, function(el) { return el.payload });
}
Expand Down
13 changes: 12 additions & 1 deletion inspirehep/modules/records/receivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,16 @@ def populate_author_suggest(sender, json, *args, **kwargs):
if 'authors.json' not in json.get('$schema'):
return

author_paths = [
'name.preferred_name',
'name.value',
'native_name',
'other_names',
'previous_names',
]

name = get_value(json, 'name.value', '')
input_values = [name]
input_values = [el for el in chain.from_iterable([force_list(get_value(json, path)) for path in author_paths])]

record = get_value(json, 'self.$ref', '')

Expand Down Expand Up @@ -266,6 +274,9 @@ def populate_conference_suggest(sender, json, *args, **kwargs):
'titles.source',
'titles.subtitle',
'titles.title',
'alternative_titles.source',
'alternative_titles.subtitle',
'alternative_titles.title',
'opening_date',
]

Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/literature/test_literature_new_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ def test_journal_info_autocomplete_title(login):
def test_conference_info_autocomplete_title(login):
create_literature.go_to()
assert create_literature.write_conference(
'autrans',
'IN2P3 School of Statistics, 2012-05-28, Autrans, FR',
'IN2',
'IN2P3 School of Statistics',
).has_error()


Expand Down
29 changes: 28 additions & 1 deletion tests/unit/records/test_records_receivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,19 @@ def test_populate_author_suggest():
record = {
'$schema': 'http://localhost:5000/schemas/records/authors.json',
'name': {
'preferred_name': 'Alexander Aab',
'value': 'Aab, Alexander',
},
'native_name': [
'Alexandru, Aab',
],
'other_names': [
'Alexandru, Ab',
'Alexander, Ab',
],
'previous_names': [
'Alexis, Aban'
],
'self': {
'$ref': 'http://localhost:5000/api/authors/bar'
},
Expand All @@ -68,7 +79,13 @@ def test_populate_author_suggest():
populate_author_suggest(None, record)

expected = {
'input': ['Aab, Alexander'],
'input': ['Alexander Aab',
'Aab, Alexander',
'Alexandru, Aab',
'Alexandru, Ab',
'Alexander, Ab',
'Alexis, Aban',
],
'output': 'Aab, Alexander',
'payload': {
'$ref': 'http://localhost:5000/api/authors/bar',
Expand Down Expand Up @@ -496,6 +513,13 @@ def test_populate_conference_suggest():
'title': 'A title',
},
],
'alternative_titles': [
{
'source': 'An alternative source',
'subtitle': 'An alternative subtitle',
'title': 'An alternative title',
},
],
'opening_date': '2009-03-12',
'self': {
'$ref': 'http://localhost:5000/api/conferences/bar'
Expand All @@ -520,6 +544,9 @@ def test_populate_conference_suggest():
'A source',
'A subtitle',
'A title',
'An alternative source',
'An alternative subtitle',
'An alternative title',
'2009-03-12',
'Batavia',
'Berlin',
Expand Down

0 comments on commit 3afcd77

Please sign in to comment.