Skip to content

Commit

Permalink
Merge pull request #65 from golnazads/master
Browse files Browse the repository at this point in the history
fixed re for bibstems that included &, and 1-4, ie A&A, GCN1, -CLic2, JPhy3, -JPhy4
  • Loading branch information
golnazads committed Mar 28, 2019
2 parents 75e9a86 + bdab39d commit f73407d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions tugboat/tests/tests_unit/test_search_redirect.py
Expand Up @@ -921,5 +921,13 @@ def test_ref_stems(self):
'-bibstem:(' + urllib.quote('"AAS"') + ')' +
'&sort=' + urllib.quote('date desc, bibcode desc') + '/', search)

req.args = MultiDict([('ref_stems', 'A&A, GCN1, -CLic2, JPhy3, -JPhy4')])
req.args.update(self.append_defaults())
view = ClassicSearchRedirectView()
search = view.translate(req)
self.assertEqual('q=bibstem:(' + urllib.quote('"A&A"') + ' OR ' + urllib.quote('"GCN1"') + ' OR ' + urllib.quote('"JPhy3"') + ') AND ' +
'-bibstem:(' + urllib.quote('"CLic2"') + ' OR ' + urllib.quote('"JPhy4"') + ')' +
'&sort=' + urllib.quote('date desc, bibcode desc') + '/', search)

if __name__ == '__main__':
unittest.main(verbosity=2)
3 changes: 2 additions & 1 deletion tugboat/views.py
Expand Up @@ -1045,7 +1045,8 @@ def translate_ref_stems(self, args):
# not validating, just pass it to BBB, if any bibstem has been specified
ref_stems = ''
if len(value) > 0:
match = re.findall('([-+]*[A-Za-z]{2,5})', value)
# there is A&A, GCN1, CLic2, JPhy3, JPhy4
match = re.findall('([-+]*[A-Za-z&1-4]{2,5})', value)
# yes
if match:
ref_stems_positive = ''
Expand Down

0 comments on commit f73407d

Please sign in to comment.