Example #1
0
def collection_csv(collection):
    collection = get_collection(collection, authz.READ)
    schema = request.args.get('$schema')
    if schema is None:
        raise BadRequest()
    results = collection_entities(collection, depth=get_depth(2),
                                  filter_schema=schema)
    visitor, table = entities_to_table(schema, results)
    basename = '%s - %s' % (collection.title, visitor.plural)
    return make_csv_response(table, basename)
Example #2
0
def collection_csv(collection):
    collection = get_collection(collection, authz.READ)
    schema = request.args.get('$schema')
    if schema is None:
        raise BadRequest()
    results = collection_entities(collection,
                                  depth=get_depth(2),
                                  filter_schema=schema)
    visitor, table = entities_to_table(schema, results)
    basename = '%s - %s' % (collection.title, visitor.plural)
    return make_csv_response(table, basename)
Example #3
0
def collection_xlsx(collection):
    collection = get_collection(collection, authz.READ)
    results = collection_entities(collection, depth=get_depth(2),
                                  filter_schema=request.args.get('$schema'))
    by_schema = OrderedDict()
    for result in results:
        by_schema.setdefault(result.get('$schema'), [])
        by_schema[result.get('$schema')].append(result)
    sheets = OrderedDict()
    for schema, schema_results in by_schema.items():
        schema_results = list(schema_results)
        visitor, table = entities_to_table(schema, schema_results)
        sheets[visitor.plural] = table

    if '$schema' in request.args and len(sheets):
        basename = '%s - %s' % (collection.title, sheets.keys()[0])
    else:
        basename = collection.title
    return make_xlsx_response(sheets, basename)
Example #4
0
def collection_xlsx(collection):
    collection = get_collection(collection, authz.READ)
    results = collection_entities(collection,
                                  depth=get_depth(2),
                                  filter_schema=request.args.get('$schema'))
    by_schema = OrderedDict()
    for result in results:
        by_schema.setdefault(result.get('$schema'), [])
        by_schema[result.get('$schema')].append(result)
    sheets = OrderedDict()
    for schema, schema_results in by_schema.items():
        schema_results = list(schema_results)
        visitor, table = entities_to_table(schema, schema_results)
        sheets[visitor.plural] = table

    if '$schema' in request.args and len(sheets):
        basename = '%s - %s' % (collection.title, sheets.keys()[0])
    else:
        basename = collection.title
    return make_xlsx_response(sheets, basename)