示例#1
0
def taxon_count(args, id):
    data = {}
    taxon = Taxon.query.get_or_404(id)
    for relation in args['relation']:
        _, base = relation.rsplit('/', 1)
        data[base] = utils.count_relation(taxon, relation)
    return utils.json_response(data)
示例#2
0
def accession_count(args, id):
    data = {}
    accession = Accession.query.get_or_404(id)
    for relation in args['relation']:
        _, base = relation.rsplit('/', 1)
        data[base] = utils.count_relation(accession, relation)
    return utils.json_response(data)
示例#3
0
def genus_count(args, id):
    data = {}
    genus = Genus.query.get_or_404(id)
    for relation in args['relation']:
        _, base = relation.rsplit('/', 1)
        data[base] = utils.count_relation(genus, relation)
    return utils.json_response(data)
示例#4
0
def family_count(args, family_id):
    data = {}
    family = Family.query.get_or_404(family_id)
    for relation in args['relation']:
        _, base = relation.rsplit('/', 1)
        data[base] = utils.count_relation(family, relation)
    return utils.json_response(data)
示例#5
0
def location_count(args, location_id):
    data = {}
    location = Location.query.get_or_404(location_id)
    for relation in args['relation']:
        _, base = relation.rsplit('/', 1)
        data[base] = utils.count_relation(location, relation)
    return utils.json_response(data)
示例#6
0
def plant_count(args, id):
    data = {}
    plant = Plant.query.get_or_404(id)
    for relation in args['relation']:
        _, base = relation.rsplit('/', 1)
        data[base] = utils.count_relation(plant, relation)
    return utils.json_response(data)
示例#7
0
def genus_count(args, id):
    data = {}
    genus = Genus.query.get_or_404(id)
    for relation in args['relation']:
        _, base = relation.rsplit('/', 1)
        data[base] = utils.count_relation(genus, relation)
    return utils.json_response(data)
示例#8
0
def family_count(args, family_id):
    data = {}
    family = Family.query.get_or_404(family_id)
    for relation in args['relation']:
        _, base = relation.rsplit('/', 1)
        data[base] = utils.count_relation(family, relation)
    return utils.json_response(data)
示例#9
0
def location_count(args, location_id):
    data = {}
    location = Location.query.get_or_404(location_id)
    for relation in args['relation']:
        _, base = relation.rsplit('/', 1)
        data[base] = utils.count_relation(location, relation)
    return utils.json_response(data)
示例#10
0
def show(id):
    taxon = Taxon.query \
                 .options(orm.joinedload(*Taxon.synonyms.attr)) \
                 .get_or_404(id)
    if request.prefers_json:
        return resource.render_json(taxon)

    relations = ['/accessions', '/accessions/plants']
    counts = {}
    for relation in relations:
        _, base = relation.rsplit('/', 1)
        counts[base] = utils.count_relation(taxon, relation)

    return resource.render_html(taxon=taxon, counts=counts)
示例#11
0
def show(id):
    genus = Genus.query \
                 .options(orm.joinedload(*Genus.synonyms.attr)) \
                 .get_or_404(id)
    if request.prefers_json:
        return resource.render_json(genus)

    relations = ['/taxa', '/taxa/accessions', '/taxa/accessions/plants']
    counts = {}
    for relation in relations:
        _, base = relation.rsplit('/', 1)
        counts[base] = utils.count_relation(genus, relation)

    return resource.render_html(genus=genus, counts=counts)
示例#12
0
def show(id):
    family = Family.query \
                   .options(orm.joinedload(*Family.synonyms.attr)) \
                   .get_or_404(id)
    if request.prefers_json:
        return resource.render_json(family)

    relations = ['/genera', '/genera/taxa', '/genera/taxa/accessions',
                 '/genera/taxa/accessions/plants']
    counts = {}
    for relation in relations:
        _, base = relation.rsplit('/', 1)
        counts[base] = utils.count_relation(family, relation)

    return resource.render_html(family=family, counts=counts)
示例#13
0
def show(id):
    family = Family.query \
                   .options(orm.joinedload(*Family.synonyms.attr)) \
                   .get_or_404(id)
    if request.prefers_json:
        return resource.render_json(family)

    relations = [
        '/genera', '/genera/taxa', '/genera/taxa/accessions',
        '/genera/taxa/accessions/plants'
    ]
    counts = {}
    for relation in relations:
        _, base = relation.rsplit('/', 1)
        counts[base] = utils.count_relation(family, relation)

    return resource.render_html(family=family, counts=counts)