mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 06:22:24 +01:00
Fix crash on review votes page
This commit is contained in:
parent
2e8ddb8ca4
commit
12664a4f41
@ -245,15 +245,17 @@ def review_votes(package):
|
|||||||
else:
|
else:
|
||||||
user_biases[vote.user.username][1] += 1
|
user_biases[vote.user.username][1] += 1
|
||||||
|
|
||||||
|
reviews = package.reviews.all()
|
||||||
|
|
||||||
BiasInfo = namedtuple("BiasInfo", "username balance with_ against no_vote perc_with")
|
BiasInfo = namedtuple("BiasInfo", "username balance with_ against no_vote perc_with")
|
||||||
user_biases_info = []
|
user_biases_info = []
|
||||||
for username, bias in user_biases.items():
|
for username, bias in user_biases.items():
|
||||||
total_votes = bias[0] + bias[1]
|
total_votes = bias[0] + bias[1]
|
||||||
balance = bias[0] - bias[1]
|
balance = bias[0] - bias[1]
|
||||||
perc_with = round((100 * bias[0]) / total_votes)
|
perc_with = round((100 * bias[0]) / total_votes)
|
||||||
user_biases_info.append(BiasInfo(username, balance, bias[0], bias[1], len(package.reviews) - total_votes, perc_with))
|
user_biases_info.append(BiasInfo(username, balance, bias[0], bias[1], len(reviews) - total_votes, perc_with))
|
||||||
|
|
||||||
user_biases_info.sort(key=lambda x: -abs(x.balance))
|
user_biases_info.sort(key=lambda x: -abs(x.balance))
|
||||||
|
|
||||||
return render_template("packages/review_votes.html", package=package, reviews=package.reviews,
|
return render_template("packages/review_votes.html", package=package, reviews=reviews,
|
||||||
user_biases=user_biases_info)
|
user_biases=user_biases_info)
|
||||||
|
@ -77,11 +77,8 @@
|
|||||||
<span class="btn" title="{{ _('Reviews') }}">
|
<span class="btn" title="{{ _('Reviews') }}">
|
||||||
<i class="fas fa-star-half-alt"></i>
|
<i class="fas fa-star-half-alt"></i>
|
||||||
<span class="count">
|
<span class="count">
|
||||||
+{{ package.reviews | selectattr("rating", "equalto", 5) | list | length }}
|
{% set summary = package.get_review_summary() %}
|
||||||
/
|
+{{ summary[0] }} / {{ summary[1] }} / -{{ summary[2] }}
|
||||||
{{ package.reviews | selectattr("rating", "equalto", 3) | list | length }}
|
|
||||||
/
|
|
||||||
-{{ package.reviews | selectattr("rating", "equalto", 1) | list | length }}
|
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user