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 )
def abstract(bibcode=None): if bibcode is None: abort(404) solrdoc = get_document(bibcode) if not solrdoc: abort(404) denormdoc = denormalize_solr_doc(solrdoc) # log the request abstract_view_signal.send(abs_blueprint, bibcode=bibcode, list_type="abstract") statsd.incr("abs.abstract.viewed") return render_template("abstract_tabs.html", solrdoc=solrdoc, denormdoc=denormdoc, curview="abstract")
def abstract(bibcode=None): if bibcode is None: abort(404) solrdoc = get_document(bibcode) if not solrdoc: abort(404) denormdoc = denormalize_solr_doc(solrdoc) # get article graphics info graphics = get_thumbnails(bibcode) # log the request abstract_view_signal.send(abs_blueprint, bibcode=bibcode, list_type="abstract") statsd.incr("abs.abstract.viewed") return render_template('abstract_tabs.html', solrdoc=solrdoc, denormdoc=denormdoc, graphics=graphics, curview='abstract')
def test_denormalize(self): data = { "author":["Quest, Cosmo", "Schlegel, David J.", "Finkbeiner, Douglas P.", "Davis, Marc"], "keyword":["cosmology diffuse radiation", "cosmology cosmic microwave background", "ism dust extinction", "interplanetary medium", "astronomy infrared", "Astrophysics"], "keyword_norm":["cosmology diffuse radiation", "cosmology cosmic microwave background", "ism dust extinction", "interplanetary medium", "astronomy infrared", "astrophysics"], 'keyword_schema': ['ADS', 'ADS', 'ADS', 'ADS', '-', 'foo'], "aff":["aff1", "aff2;aff2b", "aff3", "-" ], "email":["*****@*****.**", "[email protected] [email protected]", "-", "-" ], "bibcode":"1907PASP...19..240K", "title": ["An Artist's View of the Next Generation ADS Digital Library System"], } solrdoc = SolrDocument(data) newdoc = denormalize_solr_doc(solrdoc) expected = {'author': [{'affiliation': 'aff1', 'email': '*****@*****.**', 'name': 'Quest, Cosmo'}, {'affiliation': 'aff2;aff2b', 'email': '[email protected] [email protected]', 'name': 'Schlegel, David J.'}, {'affiliation': 'aff3', 'name': 'Finkbeiner, Douglas P.'}, {'name': 'Davis, Marc'}], 'bibcode': '1907PASP...19..240K', 'keyword': {'ADS': ['cosmology cosmic microwave background', 'cosmology diffuse radiation', 'interplanetary medium', 'ism dust extinction'], 'Free Keywords': ['astronomy infrared'], 'foo': ['Astrophysics']}, "keyword_norm":["cosmology diffuse radiation", "cosmology cosmic microwave background", "ism dust extinction", "interplanetary medium", "astronomy infrared", "astrophysics"], 'title': "An Artist's View of the Next Generation ADS Digital Library System", 'links': {}, 'afflen': 3} self.maxDiff = None self.assertEqual(expected, newdoc.data)
def test_denormalize(self): data = { "author":["Quest, Cosmo", "Schlegel, David J.", "Finkbeiner, Douglas P.", "Davis, Marc"], "keyword":["cosmology diffuse radiation", "cosmology cosmic microwave background", "ism dust extinction", "ism dust extinction", "interplanetary medium", "astronomy infrared", "astrophysics", "COSMOLOGY: DIFFUSE RADIATION", "COSMOLOGY: COSMIC MICROWAVE BACKGROUND", "ISM: DUST", "EXTINCTION", "INTERPLANETARY MEDIUM", "INFRARED: ISM: CONTINUUM", "Astrophysics", "cosmology diffuse radiation", "cosmology cosmic microwave background", "ism dust extinction", "ism dust extinction", "interplanetary medium", "astronomy infrared", "astrophysics"], "keyword_norm":["cosmology diffuse radiation", "cosmology cosmic microwave background", "ism dust extinction", "ism dust extinction", "interplanetary medium", "astronomy infrared", "astrophysics"], 'keyword_schema': ['ADS', 'ADS', 'ADS', 'ADS', 'foo', 'ADS', 'foo'], "aff":["aff1", "aff2;aff2b", "aff3", # 4th missing intentionally ], "email":["*****@*****.**", "[email protected] [email protected]"], "bibcode":"1907PASP...19..240K", "title": ["An Artist's View of the Next Generation ADS Digital Library System"], } solrdoc = SolrDocument(data) newdoc = denormalize_solr_doc(solrdoc) expected = {'author': [{'affiliation': 'aff1', 'email': '*****@*****.**', 'name': 'Quest, Cosmo'}, {'affiliation': 'aff2;aff2b', 'email': '[email protected] [email protected]', 'name': 'Schlegel, David J.'}, {'affiliation': 'aff3', 'name': 'Finkbeiner, Douglas P.'}, {'name': 'Davis, Marc'}], 'bibcode': '1907PASP...19..240K', 'keyword': ['Astrophysics', 'COSMOLOGY: COSMIC MICROWAVE BACKGROUND', 'COSMOLOGY: DIFFUSE RADIATION', 'EXTINCTION', 'INFRARED: ISM: CONTINUUM', 'INTERPLANETARY MEDIUM', 'ISM: DUST', 'astronomy infrared', 'astrophysics', 'cosmology cosmic microwave background', 'cosmology diffuse radiation', 'interplanetary medium', 'ism dust extinction'], 'keyword_norm': {'ADS': ['astronomy infrared', 'cosmology cosmic microwave background', 'cosmology diffuse radiation', 'ism dust extinction'], 'foo': ['astrophysics', 'interplanetary medium']}, 'title': "An Artist's View of the Next Generation ADS Digital Library System"} self.assertEqual(expected, newdoc.data)