forked from rDrama/rDrama
1
0
Fork 0

leaderboards: workaround jinja can't do this by setting a value for if v appears in ranking

master
justcool393 2022-11-01 02:57:10 -05:00
parent 40a34ea26a
commit 5c32713469
2 changed files with 3 additions and 3 deletions

View File

@ -17,6 +17,7 @@ class Leaderboard:
all_users = None all_users = None
v_position = 0 v_position = 0
v_value = None v_value = None
v_appears_in_ranking = False
user_func = None user_func = None
value_func = None value_func = None
@ -33,6 +34,7 @@ class Leaderboard:
self.all_users = lb[0] self.all_users = lb[0]
self.v_position = lb[1] self.v_position = lb[1]
self.v_value = lb[2] self.v_value = lb[2]
self.v_appears_in_ranking = self.v_position <= limit
if value_func: if value_func:
self.user_func = lambda u:u self.user_func = lambda u:u
self.value_func = value_func self.value_func = value_func

View File

@ -35,16 +35,14 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% set v_appears_in_ranking = false %}
{% for user in lb.all_users %} {% for user in lb.all_users %}
{% set user2 = lb.user_func(user) %} {% set user2 = lb.user_func(user) %}
{% if v.id == user2.id %} {% if v.id == user2.id %}
{% set style="class=\"self\"" %} {% set style="class=\"self\"" %}
{% set v_appears_in_ranking = true %}
{% endif %} {% endif %}
{{format_user_in_table(user2, style, loop.index, lb.value_func(user), lb.user_relative_url)}} {{format_user_in_table(user2, style, loop.index, lb.value_func(user), lb.user_relative_url)}}
{% endfor %} {% endfor %}
{% if lb.v_position and not v_appears_in_ranking %} {% if lb.v_position and not lb.v_appears_in_ranking %}
{{format_user_in_table(v, "style=\"border-top:2px solid var(--primary)\"", lb.v_position, lb.v_value, lb.user_relative_url)}} {{format_user_in_table(v, "style=\"border-top:2px solid var(--primary)\"", lb.v_position, lb.v_value, lb.user_relative_url)}}
{% endif %} {% endif %}
</tbody> </tbody>