fix(FastAPI): get_pkgbase -> get_pkg_or_base

`get_pkgbase` has been replaced with `get_pkg_or_base`, which is
quite similar, but it does take a new `cls` keyword argument which
is to be the model class which we search for via its `Name` column.

Additionally, this change fixes a bug in the `/packages/{name}` route
by supplying the Package object in question to the context and modifying
the template to use it instead of a hacky through-base workaround.

Examples:

    pkgbase = get_pkg_or_base("some_pkgbase_name", PackageBase)
    pkg = get_pkg_or_base("some_package_name", Package)

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-09-27 14:58:07 -07:00
parent f849e8b696
commit 5e95cfbc8a
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
3 changed files with 19 additions and 16 deletions

View file

@ -3,7 +3,7 @@
{% block pageContent %}
{% include "partials/packages/search.html" %}
<div id="pkgdetails" class="box">
<h2>{{ 'Package Details' | tr }}: {{ pkgbase.Name }} {{ pkgbase.packages.first().Version }}</h2>
<h2>{{ 'Package Details' | tr }}: {{ package.Name }} {{ package.Version }}</h2>
{% set result = pkgbase %}
{% include "partials/packages/actions.html" %}