Skip to content

Commit

Permalink
Merge pull request #80 from golnazads/master
Browse files Browse the repository at this point in the history
remove all ANDED warnings, we are accepting ORs now too
  • Loading branch information
golnazads committed Oct 31, 2019
2 parents af246a9 + e3a48d3 commit dfb08ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
6 changes: 2 additions & 4 deletions tugboat/tests/tests_unit/test_search_redirect.py
Expand Up @@ -151,8 +151,7 @@ def test_title(self):
search = view.translate(req)
self.assertEqual('q=' +
urllib.quote('title:') + '(' + urllib.quote('ADS Kurtz') + ')' +
'&sort=' + urllib.quote('date desc, bibcode desc') + '&format=SHORT' +
'&warning_message=' + 'TITLE_ANDED_WARNING' + '/', search) # single object
'&sort=' + urllib.quote('date desc, bibcode desc') + '&format=SHORT' + '/', search) # single object

def test_text(self):
"""text search"""
Expand All @@ -173,8 +172,7 @@ def test_text(self):
search = view.translate(req)
self.assertEqual('q=' +
urllib.quote('abs:') + '(' + urllib.quote('foo bar') + ')' +
'&sort=' + urllib.quote('date desc, bibcode desc') + '&format=SHORT' +
'&warning_message=' + 'ABSTRACT_ANDED_WARNING' + '/', search) # single object
'&sort=' + urllib.quote('date desc, bibcode desc') + '&format=SHORT' + '/', search) # single object

def test_pubdate(self):
"""test pubdate"""
Expand Down
24 changes: 12 additions & 12 deletions tugboat/views.py
Expand Up @@ -329,15 +329,14 @@ def supplied(value):
return False
return True

def translate_title_for_myads(self, title_str):
""" return parsed title in the form accept by BBB """
title = self.classic_field_to_string(title_str)[0].lstrip('*')
def translate_title_for_myads(self, value):
""" return classic title in the form accept by BBB """
try:
# remove the star if there is on at the beginning and call the special parser
return adsparser.parse_classic_keywords(title)
# remove the star if there is one at the beginning and call the special parser
return adsparser.parse_classic_keywords(value.lstrip('*'))
except:
# go with what it was typed
return title
# go with regular tokenizer
return self.classic_field_to_string(value)[0].lstrip('*')

def translate_myads_queries(self, args):
"""return query string for the six different myads queries"""
Expand Down Expand Up @@ -519,11 +518,12 @@ def translate_simple(self, args, classic_param, bbb_param):
else:
terms = self.classic_field_to_string(classic_str)
# issue a warning for title and abstract if multiple words are specified and OR is selected
if len(''.join(terms).split(' ')) > 1 and logic == 'OR':
if classic_param == 'title':
self.translation.warning_message.append(urllib.quote('TITLE_ANDED_WARNING'))
elif classic_param == 'text':
self.translation.warning_message.append(urllib.quote('ABSTRACT_ANDED_WARNING'))
# 10/30/2019 from Alberto: let's recognize the boolean selected by user
# if len(''.join(terms).split(' ')) > 1 and logic == 'OR':
# if classic_param == 'title':
# self.translation.warning_message.append(urllib.quote('TITLE_ANDED_WARNING'))
# elif classic_param == 'text':
# self.translation.warning_message.append(urllib.quote('ABSTRACT_ANDED_WARNING'))
search += urllib.quote(bbb_param + ':') + '('
for term in terms:
search += urllib.quote(term + connector)
Expand Down

0 comments on commit dfb08ef

Please sign in to comment.