Add fmt option to include VCS repo URL

Fixes #514
This commit is contained in:
rubenwardy
2024-06-22 17:14:52 +01:00
parent 232e3199fd
commit 3f12a89764
4 changed files with 14 additions and 6 deletions

View File

@@ -74,10 +74,12 @@ def packages():
qb = QueryBuilder(request.args, lang=lang)
query = qb.build_package_query()
if request.args.get("fmt") == "keys":
fmt = request.args.get("fmt")
if fmt == "keys":
return jsonify([pkg.as_key_dict() for pkg in query.all()])
pkgs = qb.convert_to_dictionary(query.all())
include_vcs = fmt == "vcs"
pkgs = qb.convert_to_dictionary(query.all(), include_vcs)
if "engine_version" in request.args or "protocol_version" in request.args:
pkgs = [pkg for pkg in pkgs if pkg.get("release")]
@@ -88,7 +90,8 @@ def packages():
"limit" not in request.args:
featured_lut = set()
featured = qb.convert_to_dictionary(query.filter(
Package.collections.any(and_(Collection.name == "featured", Collection.author.has(username="ContentDB")))).all())
Package.collections.any(and_(Collection.name == "featured", Collection.author.has(username="ContentDB")))).all(),
include_vcs)
for pkg in featured:
featured_lut.add(f"{pkg['author']}/{pkg['name']}")
pkg["short_description"] = gettext("Featured") + ". " + pkg["short_description"]