diff --git a/inspirehep/modules/forms/static/js/forms/affiliations_typeahead.js b/inspirehep/modules/forms/static/js/forms/affiliations_typeahead.js index 01512fdbdd..e9f76d4ad6 100644 --- a/inspirehep/modules/forms/static/js/forms/affiliations_typeahead.js +++ b/inspirehep/modules/forms/static/js/forms/affiliations_typeahead.js @@ -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 }); } diff --git a/inspirehep/modules/records/receivers.py b/inspirehep/modules/records/receivers.py index 753cae2d92..05d7b507de 100644 --- a/inspirehep/modules/records/receivers.py +++ b/inspirehep/modules/records/receivers.py @@ -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', '') @@ -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', ] diff --git a/tests/acceptance/literature/test_literature_new_form.py b/tests/acceptance/literature/test_literature_new_form.py index 59ea22c53a..f09582a6a0 100644 --- a/tests/acceptance/literature/test_literature_new_form.py +++ b/tests/acceptance/literature/test_literature_new_form.py @@ -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() diff --git a/tests/unit/records/test_records_receivers.py b/tests/unit/records/test_records_receivers.py index fea48848f8..49f8fec4ae 100644 --- a/tests/unit/records/test_records_receivers.py +++ b/tests/unit/records/test_records_receivers.py @@ -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' }, @@ -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', @@ -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' @@ -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',