From e9193aefb8167bb267a7f5534be45fba3080b4cc Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sat, 30 Mar 2024 17:27:08 +0000 Subject: [PATCH] Add favorites count to favorite button --- app/blueprints/packages/packages.py | 6 +++++- app/templates/packages/view.html | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/blueprints/packages/packages.py b/app/blueprints/packages/packages.py index 9d56a90b..3cb04190 100644 --- a/app/blueprints/packages/packages.py +++ b/app/blueprints/packages/packages.py @@ -164,6 +164,10 @@ def view(package): if package.state != PackageState.APPROVED: validation = validate_package_for_approval(package) + favorites_count = Collection.query.filter( + Collection.packages.contains(package), + Collection.name == "favorites").count() + is_favorited = current_user.is_authenticated and \ Collection.query.filter( Collection.author == current_user, @@ -173,7 +177,7 @@ def view(package): return render_template("packages/view.html", package=package, releases=releases, packages_uses=packages_uses, review_thread=review_thread, threads=threads.all(), validation=validation, - has_review=has_review, is_favorited=is_favorited) + has_review=has_review, favorites_count=favorites_count, is_favorited=is_favorited) @bp.route("/packages///shields//") diff --git a/app/templates/packages/view.html b/app/templates/packages/view.html index 2b5ceb11..f213fee7 100644 --- a/app/templates/packages/view.html +++ b/app/templates/packages/view.html @@ -385,8 +385,12 @@
-