Skip to content

Commit

Permalink
Merge pull request #53 from kelockhart/blank-author
Browse files Browse the repository at this point in the history
Fix to not import blank author in myADS
  • Loading branch information
kelockhart authored Mar 25, 2020
2 parents 3b29366 + aafc92d commit 53d1683
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions vault_service/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_exc():
@httpretty.activate
def test_upsert_myads(self):
user_id = 5
classic_setup = {"ast_aut": "Lockwood, G.\r\nKurtz, M.",
classic_setup = {"ast_aut": "Accomazzi, A.\r\nKurtz, M.",
"ast_t1": "photosphere\r\nchromosphere\r\n",
"ast_t2": "\"climate change\"\r\n\"global warming\"\r\n\"solar variation\"",
"email": "[email protected]",
Expand All @@ -50,7 +50,7 @@ def test_upsert_myads(self):
],
"id": 2060288,
"lastname": "",
"phy_aut": "Lockwood, G.",
"phy_aut": "Lockwood, G.\r\n",
"phy_t1": "photosphere\r\nchromosphere\r\n",
"phy_t2": "\"climate change\"\r\n\"global warming\"\r\n\"solar variation\"",
"pre_aut": "Lockwood, G.",
Expand All @@ -64,6 +64,9 @@ def test_upsert_myads(self):
with self.app.session_scope() as session:
q = session.query(MyADS).filter_by(user_id=user_id).all()
self.assertEquals(len(q), 4)
# make sure the blank author is removed
self.assertEquals(q[1].data, 'author:"Lockwood, G." OR author:"Accomazzi, A." OR author:"Kurtz, M."')

self.assertEquals(len(existing_setups), 0)
self.assertEquals(len(new_setups), 4)
self.assertEquals(new_setups[2], {'id': 3,
Expand Down
6 changes: 3 additions & 3 deletions vault_service/views/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,21 +334,21 @@ def _import_authors(classic_setups=None, user_id=None, active=True):
data_all = ''
if classic_setups.get('phy_aut'):
author_list = classic_setups.get('phy_aut').split('\r\n')
data = ' OR '.join(['author:"' + x + '"' for x in author_list])
data = ' OR '.join(['author:"' + x + '"' for x in author_list if x])
if data not in data_all:
if len(data_all) > 0:
data = ' OR ' + data
data_all += data
if classic_setups.get('pre_aut'):
author_list = classic_setups.get('pre_aut').split('\r\n')
data = ' OR '.join(['author:"' + x + '"' for x in author_list])
data = ' OR '.join(['author:"' + x + '"' for x in author_list if x])
if data not in data_all:
if len(data_all) > 0:
data = ' OR ' + data
data_all += data
if classic_setups.get('ast_aut'):
author_list = classic_setups.get('ast_aut').split('\r\n')
data = ' OR '.join(['author:"' + x + '"' for x in author_list])
data = ' OR '.join(['author:"' + x + '"' for x in author_list if x])
if data not in data_all:
if len(data_all) > 0:
data = ' OR ' + data
Expand Down

0 comments on commit 53d1683

Please sign in to comment.