mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-09 14:37:36 +01:00
Add package downloads badge to profile page
This commit is contained in:
parent
29bfc91683
commit
94568c851a
@ -58,6 +58,7 @@ def profile(username):
|
|||||||
.select_from(User).join(PackageReview) \
|
.select_from(User).join(PackageReview) \
|
||||||
.group_by(User.username).order_by(text("count DESC")).all()
|
.group_by(User.username).order_by(text("count DESC")).all()
|
||||||
users_by_reviews = [ username for username, _ in users_by_reviews ]
|
users_by_reviews = [ username for username, _ in users_by_reviews ]
|
||||||
|
|
||||||
review_idx = None
|
review_idx = None
|
||||||
review_percent = None
|
review_percent = None
|
||||||
try:
|
try:
|
||||||
@ -66,9 +67,14 @@ def profile(username):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
total_downloads = db.session.query(func.sum(Package.downloads)) \
|
||||||
|
.select_from(User) \
|
||||||
|
.join(User.maintained_packages) \
|
||||||
|
.filter(User.id == user.id, Package.state == PackageState.APPROVED).scalar()
|
||||||
|
|
||||||
# Process GET or invalid POST
|
# Process GET or invalid POST
|
||||||
return render_template("users/profile.html", user=user, packages=packages,
|
return render_template("users/profile.html", user=user, packages=packages,
|
||||||
review_idx=review_idx, review_percent=review_percent)
|
total_downloads=total_downloads, review_idx=review_idx, review_percent=review_percent)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/users/<username>/check/", methods=["POST"])
|
@bp.route("/users/<username>/check/", methods=["POST"])
|
||||||
|
@ -180,6 +180,42 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if total_downloads >= 50000 %}
|
||||||
|
{% if total_downloads >= 300000 %}
|
||||||
|
{% set badge_color = "gold" %}
|
||||||
|
{% elif total_downloads >= 100000 %}
|
||||||
|
{% set badge_color = "#888" %}
|
||||||
|
{% elif total_downloads >= 75000 %}
|
||||||
|
{% set badge_color = "#cd7f32" %}
|
||||||
|
{% else %}
|
||||||
|
{% set badge_color = "white" %}
|
||||||
|
{% endif %}
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body media align-items-center">
|
||||||
|
<i class="fas fa-users ml-2 mr-4 text-size" style="font-size: 45px; color: {{ badge_color }};"></i>
|
||||||
|
<div class="media-body">
|
||||||
|
<h5 class="mt-0">
|
||||||
|
{% if total_downloads >= 300000 %}
|
||||||
|
{{ _(">300k downloads") }}
|
||||||
|
{% elif total_downloads >= 100000 %}
|
||||||
|
{{ _(">100k downloads") }}
|
||||||
|
{% elif total_downloads >= 75000 %}
|
||||||
|
{{ _(">75k downloads") }}
|
||||||
|
{% else %}
|
||||||
|
{{ _(">50k downloads") }}
|
||||||
|
{% endif %}
|
||||||
|
</h5>
|
||||||
|
<p class="my-0">
|
||||||
|
{{ _("Has received %(downloads)d downloads across all packages.",
|
||||||
|
display_name=user.display_name, downloads=total_downloads) }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if current_user == user or user.checkPerm(current_user, "CHANGE_AUTHOR") %}
|
{% if current_user == user or user.checkPerm(current_user, "CHANGE_AUTHOR") %}
|
||||||
|
Loading…
Reference in New Issue
Block a user