コード例 #1
0
def post_media(request):
    """
    Post the media.

    Args:
        request (HTTPRequest): The HTTP request

    Return:
        a HTTPResponse

    """
    LOGGING.info("Post media")
    _doi = get_doi_from_request(request, "media")
    if _doi is None:
        return get_response("Bad Request - doi not found in URL", 400)
    LOGGING.debug("Post media, doi: %s", _doi)
    try:
        doi_suffix = _doi.split(DOI_PREFIX, 1)[1]
    except IndexError:
        return get_response(
            "Bad Request - wrong prefix, doi should start "
            "with %s" % DOI_PREFIX, 400)

    if not is_authorized(request, doi_suffix):
        return get_response("Unauthorized - insufficient privileges", 403)

    url = urljoin(DATACITE_URL, request.get_full_path())
    return _post(url, request.body, _get_content_type_header(request))
コード例 #2
0
ファイル: delete.py プロジェクト: antony-wilson/doi_site
def delete_metadata(request):
    """
    Delete the metadata for the DOI.

    Args:
        request (HTTPRequest): The HTTP request

    Return:
        a HTTPResponse

    """
    _doi = get_doi_from_request(request, 'metadata')
    LOGGING.info('Delete metadata doi: %s', _doi)
    url = urljoin(DATACITE_URL, request.get_full_path())
    try:
        doi_suffix = _doi.split(DOI_PREFIX, 1)[1]
    except IndexError:
        return get_response("Bad Request - wrong prefix, doi should start " \
                            "with %s" % DOI_PREFIX, 400)

    if not is_authorized(request, doi_suffix):
        return get_response("Unauthorized - insufficient privileges", 403)
    return _delete(url)
コード例 #3
0
ファイル: delete.py プロジェクト: bhavanaananda/doi_site
def delete_metadata(request):
    """
    Delete the metadata for the DOI.

    Args:
        request (HTTPRequest): The HTTP request

    Return:
        a HTTPResponse

    """
    _doi = get_doi_from_request(request, 'metadata')
    LOGGING.info('Delete metadata doi: %s', _doi)
    url = urljoin(DATACITE_URL, request.get_full_path())
    try:
        doi_suffix = _doi.split(DOI_PREFIX, 1)[1]
    except IndexError:
        return get_response("Bad Request - wrong prefix, doi should start " \
                            "with %s" % DOI_PREFIX, 400)

    if not is_authorized(request, doi_suffix):
        return get_response("Unauthorized - insufficient privileges", 403)
    return _delete(url)