Exemple #1
0
def get_structures(request: Request,
                   params: EntryListingQueryParams = Depends()):

    context = {"request": request}

    try:
        response = get_entries(
            collection=structures_coll,
            response=StructureResponseMany,
            request=request,
            params=params,
        )

    except Exception as exc:
        context.update(query_error=exc,
                       query_str=str(request.url).split("filter=")[-1])

        return TEMPLATES.TemplateResponse("error.html", context)

    context.update(query=response.meta.query.representation)

    if response.meta.data_returned < 1:
        return TEMPLATES.TemplateResponse("no_structures_found.html", context)

    context.update({
        "odbx_title": "odbx",
        "odbx_blurb": "the open database of xtals",
        "odbx_about":
        'odbx is a public database of crystal structures from the group of <a href="https://ajm143.github.io">Dr Andrew Morris</a> at the University of Birmingham.',
        "data_available": response.meta.data_returned,
        "results": response.data,
        "n_results": len(response.data),
    })

    return TEMPLATES.TemplateResponse("structures.html", context)
def get_references(request: Request, params: EntryListingQueryParams = Depends()):
    return get_entries(
        collection=references_coll,
        response=ReferenceResponseMany,
        request=request,
        params=params,
    )
def get_links(
    request: Request, params: EntryListingQueryParams = Depends()
) -> LinksResponse:
    return get_entries(collection=links_coll,
                       response=LinksResponse,
                       request=request,
                       params=params)
def get_structures(request: Request,
                   params: EntryListingQueryParams = Depends()):
    return get_entries(
        collection=structures_coll,
        response=StructureResponseMany,
        request=request,
        params=params,
    )