mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-08 22:17:34 +01:00
Add favorites count to favorite button
This commit is contained in:
parent
64414a3731
commit
e9193aefb8
@ -164,6 +164,10 @@ def view(package):
|
|||||||
if package.state != PackageState.APPROVED:
|
if package.state != PackageState.APPROVED:
|
||||||
validation = validate_package_for_approval(package)
|
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 \
|
is_favorited = current_user.is_authenticated and \
|
||||||
Collection.query.filter(
|
Collection.query.filter(
|
||||||
Collection.author == current_user,
|
Collection.author == current_user,
|
||||||
@ -173,7 +177,7 @@ def view(package):
|
|||||||
return render_template("packages/view.html",
|
return render_template("packages/view.html",
|
||||||
package=package, releases=releases, packages_uses=packages_uses,
|
package=package, releases=releases, packages_uses=packages_uses,
|
||||||
review_thread=review_thread, threads=threads.all(), validation=validation,
|
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/<author>/<name>/shields/<type>/")
|
@bp.route("/packages/<author>/<name>/shields/<type>/")
|
||||||
|
@ -385,8 +385,12 @@
|
|||||||
<div class="d-flex mt-3 mb-4">
|
<div class="d-flex mt-3 mb-4">
|
||||||
<form method="POST" action="{{ package.get_url('collections.package_toggle_favorite') }}">
|
<form method="POST" action="{{ package.get_url('collections.package_toggle_favorite') }}">
|
||||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||||
<button type="submit" class="btn {% if is_favorited %}text-info{% endif %} btn-secondary me-2" aria-label="{{ _('Favorite') }}">
|
<button type="submit" class="btn {% if is_favorited %}text-info{% endif %} btn-secondary me-2"
|
||||||
|
aria-label="{{ _('Favorite') }}" title="{{ _('Favorite') }}">
|
||||||
<i class="fas fa-star"></i>
|
<i class="fas fa-star"></i>
|
||||||
|
<span class="ms-1">
|
||||||
|
{{ favorites_count }}
|
||||||
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<div class="flex-grow-1">
|
<div class="flex-grow-1">
|
||||||
|
Loading…
Reference in New Issue
Block a user