예제 #1
0
 def test_start_page(self):
     
     request_values = CombinedMultiDict([ImmutableMultiDict([('page', '2')]), ImmutableMultiDict([])])
     expected = deepcopy(QueryBuilderSimple.DEFAULT_COMPONENTS)
     expected['start'] = str((int(request_values.get('page')) - 1) * int(config.SEARCH_DEFAULT_ROWS))
     actual = QueryBuilderSimple.build(request_values)
     self.assertEqual(actual, expected)
예제 #2
0
 def test_re_sort_and_sort_dir(self):
     
     request_values = CombinedMultiDict([ImmutableMultiDict([('re_sort_type', 'RELEVANCE'), ('re_sort_dir', 'asc')]), ImmutableMultiDict([])])
     expected = deepcopy(QueryBuilderSimple.DEFAULT_COMPONENTS)
     expected['sort'] = ('score','asc')
     actual = QueryBuilderSimple.build(request_values)
     self.assertEqual(actual, expected)
예제 #3
0
파일: views.py 프로젝트: romanchyla/adsabs
def tab_list(bibcode, list_type):

    #I get the document
    solrdoc = get_document(bibcode)

    #if there are no references I return a 404
    if not solrdoc or not solrdoc.has_assoc_list(list_type):
        abort(404)

    #I get the additional metadata
    inveniodoc = invenio.get_invenio_metadata(bibcode)

    #I parse the get options 
    query_components = QueryBuilderSimple.build(request.values, list_type=list_type)

    # use the appropriate getter method
    list_method = getattr(solrdoc, "get_%s" % list_type)
    if not list_method:
        abort(404)

    #I get the list of associated docs
    resp = list_method(**query_components)
    
    # log the request
    abstract_view_signal.send(abs_blueprint, bibcode=bibcode, type=list_type)
    
    return render_template('abstract_tabs.html', solrdoc=solrdoc, inveniodoc=inveniodoc, curview=list_type, article_list=resp)
예제 #4
0
파일: views.py 프로젝트: rahuldave/adsabs
def tab_list(bibcode, list_type):

    solrdoc = get_document(bibcode)

    # if there are no references return a 404
    if not solrdoc or not solrdoc.has_assoc_list(list_type):
        abort(404)

    denormdoc = denormalize_solr_doc(solrdoc)

    # parse the get options
    query_components = QueryBuilderSimple.build(request.values, list_type=list_type)

    # use the appropriate getter method
    list_method = getattr(solrdoc, "get_%s" % list_type)
    if not list_method:
        abort(404)

    # get the list of associated docs
    resp = list_method(**query_components)

    # log the request
    abstract_view_signal.send(abs_blueprint, bibcode=bibcode, list_type=list_type)
    statsd.incr("abs.%s.viewed" % list_type)

    return render_template(
        "abstract_tabs.html", solrdoc=solrdoc, denormdoc=denormdoc, curview=list_type, article_list=resp
    )
예제 #5
0
 def test_no_parameters_from_request(self):
     request_values = CombinedMultiDict([ImmutableMultiDict([]), ImmutableMultiDict([])])
     expected = deepcopy(QueryBuilderSimple.DEFAULT_COMPONENTS)
     actual = QueryBuilderSimple.build(request_values)
     self.assertEqual(actual, expected)
예제 #6
0
 def test_re_sort(self):
     request_values = CombinedMultiDict([ImmutableMultiDict([('re_sort_type', 'RELEVANCE')]), ImmutableMultiDict([])])
     expected = deepcopy(QueryBuilderSimple.DEFAULT_COMPONENTS)
     expected['sort'] = [('score', 'desc'), config.SEARCH_DEFAULT_SECONDARY_SORT]
     actual = QueryBuilderSimple.build(request_values)
     self.assertEqual(actual, expected)