diff --git a/files/classes/user.py b/files/classes/user.py index a26a1199b..c9073110e 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -587,12 +587,6 @@ class User(Base): def fullname(self): return f"u_{self.id}" - @property - @lazy - def banned_by(self): - if not self.is_suspended: return None - return g.db.get(User, self.is_banned) - @lazy def has_badge(self, badge_id): return g.db.query(Badge).filter_by(user_id=self.id, badge_id=badge_id).one_or_none() @@ -631,6 +625,28 @@ class User(Base): return f"Unban in {text}" + @property + @lazy + def unchud_string(self): + if self.chud == 1: + return "permanently chudded" + + wait = self.chud - int(time.time()) + + if wait < 60: + text = f"{wait}s" + else: + days = wait//(24*60*60) + wait -= days*24*60*60 + + hours = wait//(60*60) + wait -= hours*60*60 + + mins = wait//60 + + text = f"{days}d {hours:02d}h {mins:02d}m" + + return f"Unchud in {text}" @property @lazy @@ -1235,6 +1251,19 @@ class User(Base): def shadowbanner(self): return g.db.query(User.username).filter_by(id=self.shadowbanned).one()[0] + @property + @lazy + def banned_by(self): + username = g.db.query(User.username).filter_by(id=self.is_banned).one()[0] + return f'@{username}' + + @property + @lazy + def chudder(self): + if not self.chudded_by: return 'award' + username = g.db.query(User.username).filter_by(id=self.chudded_by).one()[0] + return f'@{username}' + @property @lazy def alts(self): diff --git a/files/templates/banned.html b/files/templates/banned.html index 561322347..0b437b12d 100644 --- a/files/templates/banned.html +++ b/files/templates/banned.html @@ -26,11 +26,7 @@ {%- endif %} {{user.truescore}} {% if user.ban_reason %}{{user.ban_reason | safe}}{% else %}No reason{% endif %} - {% with user=user.banned_by %} - - {% include "user_in_table.html" %} - - {% endwith %} + {{user.banned_by | safe}} {% endfor %} diff --git a/files/templates/chuds.html b/files/templates/chuds.html index 14957fa42..399a362dd 100644 --- a/files/templates/chuds.html +++ b/files/templates/chuds.html @@ -12,6 +12,7 @@ Last Active {%- endif %} Truescore + Chudded by Unchud in @@ -23,6 +24,7 @@ {%- endif %} {{user.truescore}} + {{user.chudder | safe}} {% endfor %} diff --git a/files/templates/userpage/admintools.html b/files/templates/userpage/admintools.html index a0f83f7d1..8dea1b593 100644 --- a/files/templates/userpage/admintools.html +++ b/files/templates/userpage/admintools.html @@ -1,21 +1,31 @@ {% macro userBanBlock(deviceType) %} + {% if u.chud %} +
CHUDDED USER: + (by {{u.chudder | safe}}) + + {% if u.chud > 1 %} + - {{u.unchud_string}} + {% endif %} +
+ {% endif %} {% if u.is_suspended %} -
BANNED USER - {% if u.ban_reason %}: +
BANNED USER: {{u.ban_reason | safe}} - {% endif %} - (by @{{u.banned_by.username}}) + + {% if not u.ban_reason.startswith('1-Day ban award used by') %} + (by {{u.banned_by | safe}}) + {% endif %} + + {% if u.unban_utc %} + - {{u.unban_string}} + {% endif %}
- {% if u.unban_utc %} -
{{u.unban_string}}
- {% endif %} {% endif %} {% if v and v.admin_level >= PERMS['USER_SHADOWBAN'] and u.shadowbanned %} -
SHADOWBANNED USER - {% if u.ban_reason %}: +
SHADOWBANNED USER: {{u.ban_reason | safe}} - {% endif %} - (by @{{u.shadowbanner}}) + + (by @{{u.shadowbanner}})
{% endif %} {% endmacro %}