Ejemplo n.º 1
0
def publication(index_id):
    r = get(pub_url + 'publication/' + index_id, params={'mimetype': 'json'}, verify=verify_cert)
    if r.status_code == 404:
        return render_template('404.html'), 404
    pubreturn = r.json()
    pubdata = munge_pubdata_for_display(pubreturn, replace_pubs_with_pubs_test, supersedes_url, json_ld_id_base_url)
    related_pubs = extract_related_pub_info(pubdata)
    if 'mimetype' in request.args and request.args.get("mimetype") == 'json':
        return jsonify(pubdata)
    else:
        return render_template('publication.html', 
                               indexID=index_id, 
                               pubdata=pubdata,
                               related_pubs=related_pubs
                               )
Ejemplo n.º 2
0
def publication(index_id):
    r = get(pub_url + 'publication/' + index_id, params={'mimetype': 'json'}, verify=verify_cert)
    if r.status_code == 404:
        return render_template('pubswh/404.html'), 404
    pubreturn = r.json()
    pubdata = munge_pubdata_for_display(pubreturn, replace_pubs_with_pubs_test, supersedes_url, json_ld_id_base_url)
    related_pubs = extract_related_pub_info(pubdata)
    if 'mimetype' in request.args and request.args.get("mimetype") == 'json':
        return jsonify(pubdata)
    if 'mimetype' in request.args and request.args.get("mimetype") == 'ris':
        content =  render_template('pubswh/ris_single.ris', result=pubdata)
        return Response(content, mimetype="application/x-research-info-systems",
                               headers={"Content-Disposition":"attachment;filename=USGS_PW_"+pubdata['indexId']+".ris"})
    else:
        return render_template('pubswh/publication.html',
                               indexID=index_id, 
                               pubdata=pubdata,
                               related_pubs=related_pubs
                               )
Ejemplo n.º 3
0
def restricted_page(index_id):
    """
    web page which is restricted and requires the user to be logged in.
    """

    # generate the auth header from the request
    auth_header = generate_auth_header(request)
    # build the url to call the endpoint
    published_status = get(pub_url + 'publication/' + index_id,
                           params={'mimetype': 'json'}, verify=verify_cert).status_code
    # go out to manage and get the record
    response = get(preview_endpoint_url+index_id+'/preview', headers=auth_header, verify=verify_cert,
                   params={'mimetype': 'json'})
    print "preview status code: ", response.status_code
    if response.status_code == 200:
        record = response.json()
        pubdata = munge_pubdata_for_display(record, replace_pubs_with_pubs_test, supersedes_url, json_ld_id_base_url)
        related_pubs = extract_related_pub_info(pubdata)
        return render_template("pubswh/preview.html", indexID=index_id, pubdata=pubdata, related_pubs=related_pubs)
    # if the publication has been published (so it is out of manage) redirect to the right URL
    elif response.status_code == 404 and published_status == 200:
        return redirect(url_for('pubwh:publication', index_id=index_id))
    elif response.status_code == 404 and published_status == 404:
        return render_template('pubswh/404.html'), 404