Beispiel #1
0
def product_page(name):
    product = _model.STORE.index.products.get_by_name(name)
    if not product:
        abort(404, "Unknown product %r" % name)
    ordered_metadata = utils.get_ordered_metadata(product.definition)

    return utils.render("product.html", product=product, metadata_doc=ordered_metadata)
Beispiel #2
0
def metadata_type_page(name):
    metadata_type = _model.STORE.index.metadata_types.get_by_name(name)
    if not metadata_type:
        abort(404, f"Unknown metadata type {name!r}")
    ordered_metadata = utils.get_ordered_metadata(metadata_type.definition)

    products_using_it = sorted(
        (p for p in _model.STORE.index.products.get_all()
         if p.metadata_type.name == name),
        key=lambda p: p.name,
    )
    return utils.render(
        "metadata-type.html",
        metadata_type=metadata_type,
        metadata_doc=ordered_metadata,
        products_using_it=products_using_it,
    )