Skip to content

Commit

Permalink
Make conference_suggest meet front-end requirements.
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 2c9316a commit c14fded
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
1 change: 0 additions & 1 deletion inspirehep/modules/forms/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ def post_process(self, form=None, formfields=[], submit=False):
field.post_process(form, formfields=formfields,
extra_processors=extra, submit=submit)


@property
def json_data(self):
"""Return form data in a format suitable for the standard JSON encoder.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ define([
var suggestionTemplate = Hogan.compile(
'<strong>{{#text}} {{ text }} {{/text}}</strong><br>' +
'<small>' +
'{{#payload.title}} {{ payload.title }} {{/payload.title}}<br>' +
'{{#payload.city}} {{ payload.city }} {{/payload.city}} ' +
'{{#payload.opening_date}} {{ payload.opening_date }} {{/payload.opening_date}}' +
'{{#payload.opening_date}} {{ payload.opening_date }}, {{/payload.opening_date}}' +
'{{#payload.city}} {{ payload.city }}, {{/payload.city}} ' +
'{{#payload.country}} {{ payload.country }} {{/payload.country}}<br>' +
'{{#payload.cnum}} {{ payload.cnum }} {{/payload.cnum}}<br>' +
'</small>'
);

Expand Down
7 changes: 5 additions & 2 deletions inspirehep/modules/records/receivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ def populate_conference_suggest(sender, json, *args, **kwargs):
conference_paths = [
'cnum',
'acronyms',
'address.country_code',
'series.name',
'titles.source',
'titles.subtitle',
Expand All @@ -276,6 +277,7 @@ def populate_conference_suggest(sender, json, *args, **kwargs):
input_values.extend(postal_addresses)
input_values = [el for el in input_values if el]

country = get_value(json, 'address.country_code', '')
cnum = json.get('cnum', '')
opening_date = json.get('opening_date', '')
record = get_value(json, 'self.$ref', '')
Expand All @@ -284,12 +286,13 @@ def populate_conference_suggest(sender, json, *args, **kwargs):
json.update({
'conference_suggest': {
'input': input_values,
'output': cnum,
'output': title[0],
'payload': {
'$ref': record,
'city': cities[0],
'country': country[0],
'opening_date': opening_date,
'title': title[0],
'cnum': cnum,
}
},
})
Expand Down
9 changes: 6 additions & 3 deletions tests/unit/records/test_records_receivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_populate_author_suggest():
assert expected == result


def test_populate_conference_suggest_does_nothing_if_record_is_not_conference():
def test_populate_author_suggest_does_nothing_if_record_is_not_author():
record = {'$schema': 'http://localhost:5000/schemas/records/other.json'}

populate_author_suggest(None, record)
Expand Down Expand Up @@ -480,6 +480,7 @@ def test_populate_conference_suggest():
'address': [
{
'cities': ['Batavia', 'Berlin'],
'country_code': 'GE',
'postal_address': ['22607 Hamburg', '1293 Bern'],
}
],
Expand Down Expand Up @@ -514,6 +515,7 @@ def test_populate_conference_suggest():
'input': [
'C87-12-25',
'SUSY 2018',
'GE',
'Conf Series',
'A source',
'A subtitle',
Expand All @@ -524,12 +526,13 @@ def test_populate_conference_suggest():
'22607 Hamburg',
'1293 Bern',
],
'output': 'C87-12-25',
'output': 'A title',
'payload': {
'$ref': 'http://localhost:5000/api/conferences/bar',
'city': 'Batavia',
'country': 'GE',
'opening_date': '2009-03-12',
'title': 'A title',
'cnum': 'C87-12-25',
},
}

Expand Down

0 comments on commit c14fded

Please sign in to comment.