forked from rDrama/rDrama
1
0
Fork 0

add lifetime_donated badges

master
Aevann 2023-05-13 00:04:26 +03:00
parent 586bd02db0
commit f3a3be1ef2
3 changed files with 29 additions and 2 deletions

View File

@ -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

View File

@ -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)

View File

@ -250,7 +250,7 @@
{% if FEATURES['BADGES'] -%}
<div id="profile--badges">
{% for b in u.badges %}
{% for b in u.ordered_badges %}
{% if b.url %}
<a class="contain" rel="nofollow noopener" href="{{b.url}}">
<img alt="{{b.name}}" width=55 height=60 loading="lazy" src="{{b.path}}" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{b.text}}" {% if b.until %}data-until="{{b.until}}" data-nonce="{{g.nonce}}" data-onmouseover="badge_timestamp(this)"{% endif %}>
@ -396,7 +396,7 @@
{% endif %}
<div class="mb-3" id="profile-mobile--badges">
{% for b in u.badges %}
{% for b in u.ordered_badges %}
{% if b.url %}
<a rel="nofollow noopener" href="{{b.url}}">
<img class="contain" alt="{{b.name}}" width=29.33 height=32 loading="lazy" src="{{b.path}}" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{b.text}}" {% if b.until %}data-until="{{b.until}}" data-nonce="{{g.nonce}}" data-onmouseover="badge_timestamp(this)"{% endif %}>