示例#1
0
def get_project_template(program, project, entity):
    """
    Return TSV template of an entity type.

    In the template, links are represented as {link_type}.{link_unique_key} for
    one_to_one and many_to_one relationships. For many_to_many relationships,
    they are represented as {link_type}.{link_unique_key}#1 to infer user the
    multiplicity.

    :param str program: |program_id|
    :param str project: |project_id|
    :param str entity: type of the entity
    :query format: output format, ``csv`` or ``tsv``, default is tsv
    :statuscode 200 Success
    :statuscode 404 Entity type is not found
    """
    file_format = flask.request.args.get('format', 'tsv')
    template = utils.entity_to_template_str(
        entity, file_format, program=program, project=project
    )
    filename = "submission_{}_template.{}".format(entity, file_format)
    response = flask.make_response(template)
    response.headers["Content-Disposition"] = (
        "attachment; filename={}".format(filename)
    )
    response.headers["Content-Type"] = "application/octet-stream"
    return response
示例#2
0
def get_template(entity):
    file_format = flask.request.args.get('format', 'tsv')
    filename = "submission_{}_template.{}".format(entity, file_format)
    template = utils.entity_to_template_str(entity, file_format)
    response = flask.make_response(template)
    content_disposition = "attachment; filename={}".format(filename)
    response.headers["Content-Disposition"] = content_disposition
    response.headers["Content-Type"] = "application/octet-stream"
    return response
示例#3
0
def get_project_template(program, project, entity):
    """
    Return TSV template of an entity type.

    In the template, links are represented as {link_type}.{link_unique_key} for
    one_to_one and many_to_one relationships. For many_to_many relationships,
    they are represented as {link_type}.{link_unique_key}#1 to infer user the
    multiplicity.

    Summary:
        Get a template for an entity type of a project

    Tags:
        dictionary

    Args:
        program (str): |program_id|
        project (str): |project_id|
        entity (str): type of the entity

    Query Args:
        format (str): output format, ``csv`` or ``tsv``, default is tsv

    Responses:
        200: Success
        404: Entity type is not found
    """
    file_format = flask.request.args.get("format", "tsv")
    template = utils.entity_to_template_str(entity,
                                            file_format,
                                            program=program,
                                            project=project)
    filename = "submission_{}_template.{}".format(entity, file_format)
    response = flask.make_response(template)
    response.headers["Content-Disposition"] = "attachment; filename={}".format(
        filename)
    response.headers["Content-Type"] = "application/octet-stream"
    return response
示例#4
0
def get_template(entity):
    """
    Get a template for an entity type.

    Summary:
        Get a template for an entity type

    Tags:
        dictionary

    Args:
        entity (str): entity

    Responses:
        200: Success.
    """
    file_format = flask.request.args.get("format", "tsv")
    filename = "submission_{}_template.{}".format(entity, file_format)
    template = utils.entity_to_template_str(entity, file_format)
    response = flask.make_response(template)
    content_disposition = "attachment; filename={}".format(filename)
    response.headers["Content-Disposition"] = content_disposition
    response.headers["Content-Type"] = "application/octet-stream"
    return response