Example #1
0
def raw_metadata_type_doc(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.prepare_document_formatting(
        metadata_type.definition, "Metadata Type", include_source_url=True)
    return utils.as_yaml(ordered_metadata)
Example #2
0
def raw_product_doc(name):
    product = _model.STORE.index.products.get_by_name(name)
    if not product:
        abort(404, f"Unknown product {name!r}")

    ordered_metadata = utils.prepare_document_formatting(
        product.definition, "Product", include_source_url=True)
    return utils.as_yaml(ordered_metadata)
Example #3
0
def product_page(name):
    product = _model.STORE.index.products.get_by_name(name)
    if not product:
        abort(404, f"Unknown product {name!r}")
    ordered_metadata = utils.prepare_document_formatting(product.definition)
    product_summary = _model.get_product_summary(name)

    return utils.render(
        "product.html",
        product=product,
        product_summary=product_summary,
        metadata_doc=ordered_metadata,
    )
Example #4
0
def raw_all_products_doc():
    resp = utils.as_yaml(*(utils.prepare_document_formatting(
        product.definition,
        f"Product {product.name}",
        include_source_url=url_for(
            ".raw_product_doc", name=product.name, _external=True),
    ) for product in _model.STORE.all_dataset_types()))
    # Add Explorer ID to the download filename if they have one.
    utils.suggest_download_filename(
        resp,
        prefix="products",
        suffix=".odc-product.yaml",
    )

    return resp
Example #5
0
def raw_all_metadata_types_doc():
    resp = utils.as_yaml(
        *(utils.prepare_document_formatting(
            type_.definition,
            f"Metadata Type {type_.name}",
            include_source_url=url_for(".raw_metadata_type_doc",
                                       name=type_.name,
                                       _external=True),
        ) for type_ in _model.STORE.all_metadata_types()), )
    # Add Explorer ID to the download filename if they have one.
    utils.suggest_download_filename(
        resp,
        prefix="metadata-types",
        suffix=".odc-type.yaml",
    )
    return resp
Example #6
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.prepare_document_formatting(
        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,
    )
Example #7
0
def product_page(name):
    product = _model.STORE.index.products.get_by_name(name)
    if not product:
        abort(404, f"Unknown product {name!r}")
    ordered_metadata = utils.prepare_document_formatting(product.definition)
    product_summary = _model.get_product_summary(name)

    extras = {}
    # (Override the global default with a product-only time.
    #  It's more useful to the user on this page, as we only show general product info.)
    if product_summary is not None:
        extras["last_updated_time"] = product_summary.last_refresh_time

    return utils.render(
        "product.html",
        product=product,
        product_summary=product_summary,
        location_samples=_model.STORE.product_location_samples(name),
        metadata_doc=ordered_metadata,
        **extras,
    )