From 9048f5127d28df07d20c1f2beda4c392c58d91d0 Mon Sep 17 00:00:00 2001 From: justcool393 Date: Tue, 1 Nov 2022 02:17:33 -0500 Subject: [PATCH] leaderboards: fix usernames in tables i think i'm not *happy* about this, something seems inelegant about this solution... --- files/classes/leaderboard.py | 4 +++- files/templates/leaderboard.html | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/files/classes/leaderboard.py b/files/classes/leaderboard.py index ad762db23..8d0b05442 100644 --- a/files/classes/leaderboard.py +++ b/files/classes/leaderboard.py @@ -17,6 +17,7 @@ class Leaderboard: all_users = None v_position = 0 v_value = None + user_func = None value_func = None def __init__(self, header_name:str, table_header_name:str, html_id:str, table_column_name:str, @@ -33,9 +34,11 @@ class Leaderboard: self.v_position = lb[1] self.v_value = lb[2] if value_func: + self.user_func = lambda u:u self.value_func = value_func self.v_value = value_func(v) else: + self.user_func = lambda u:u[0] self.value_func = lambda u: u[1] or 0 @classmethod @@ -94,4 +97,3 @@ class Leaderboard: if not position: position = (leaderboard.count() + 1, 0) leaderboard = leaderboard.limit(limit).all() return (leaderboard, position[0], position[1]) - diff --git a/files/templates/leaderboard.html b/files/templates/leaderboard.html index 62bc4e776..85201cb70 100644 --- a/files/templates/leaderboard.html +++ b/files/templates/leaderboard.html @@ -40,7 +40,7 @@ {% if v.id == user.id %} {% set style="class=\"self\"" %} {% endif %} - {{format_user_in_table(user, style, loop.index, lb.value_func(user), lb.user_relative_url)}} + {{format_user_in_table(lb.user_func(user), style, loop.index, lb.value_func(user), lb.user_relative_url)}} {% endfor %} {% if lb.v_position %} {{format_user_in_table(v, "style=\"border-top:2px solid var(--primary)\"", lb.v_position, lb.v_value, lb.user_relative_url)}}