From bdab39d270a7ecf282376887a3b4772b6c2d8f3b Mon Sep 17 00:00:00 2001 From: golnazads <28757512+golnazads@users.noreply.github.com> Date: Thu, 28 Mar 2019 12:07:47 -0400 Subject: [PATCH] fixed re for bibstems that included &, and 1-4, ie A&A, GCN1, -CLic2, JPhy3, -JPhy4 --- tugboat/tests/tests_unit/test_search_redirect.py | 8 ++++++++ tugboat/views.py | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tugboat/tests/tests_unit/test_search_redirect.py b/tugboat/tests/tests_unit/test_search_redirect.py index 6e98ff6..c99dcc3 100644 --- a/tugboat/tests/tests_unit/test_search_redirect.py +++ b/tugboat/tests/tests_unit/test_search_redirect.py @@ -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) diff --git a/tugboat/views.py b/tugboat/views.py index ce4ab15..ed85f43 100644 --- a/tugboat/views.py +++ b/tugboat/views.py @@ -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 = ''