diff --git a/files/classes/user.py b/files/classes/user.py index 50a391438..a85dd2e77 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -1223,3 +1223,15 @@ class User(Base): def can_see_my_shit(self): v = g.v return not self.shadowbanned or (v and (v.id == self.id or v.can_see_shadowbanned)) + + @property + @lazy + def ordered_badges(self): + x = sorted(self.badges, key=badge_ordering_func) + return x + +badge_ordering_tuple = (257, 258, 259, 260, 261) +def badge_ordering_func(b): + if b.badge_id in badge_ordering_tuple: + return badge_ordering_tuple.index(b.badge_id) + return b.created_utc or len(badge_ordering_tuple)+1 diff --git a/files/routes/users.py b/files/routes/users.py index e9a869130..a58b541c5 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -1359,6 +1359,21 @@ def claim_rewards(v): g.db.delete(badge) badge_grant(badge_id=20+highest_tier, user=v) + if v.lifetime_donated >= 100: + badge_grant(badge_id=257, user=v) + + if v.lifetime_donated >= 500: + badge_grant(badge_id=258, user=v) + + if v.lifetime_donated >= 2500: + badge_grant(badge_id=259, user=v) + + if v.lifetime_donated >= 5000: + badge_grant(badge_id=260, user=v) + + if v.lifetime_donated >= 10000: + badge_grant(badge_id=261, user=v) + print(f'@{v.username} rewards claimed successfully!', flush=True) diff --git a/files/templates/userpage/banner.html b/files/templates/userpage/banner.html index 043fe02b0..2795fce5d 100644 --- a/files/templates/userpage/banner.html +++ b/files/templates/userpage/banner.html @@ -250,7 +250,7 @@ {% if FEATURES['BADGES'] -%}