remotes/1693045480750635534/spooky-22
fireworks88 2021-07-28 17:37:38 +02:00
parent 027e775975
commit 091679142e
3 changed files with 26 additions and 4 deletions

View File

@ -277,6 +277,28 @@ class User(Base, Stndrd, Age_times):
def __repr__(self):
return f"<User(username={self.username})>"
@property
def unban_string(self):
if self.unban_utc == 0:
return "permanently banned"
wait = self.unban_utc - int(time.time())
if wait < 60:
text = "a few moments"
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} days {hours:02d} hours {mins:02d} minutes"
return f"Unban in {text}"
@property
@lazy
def post_notifications_count(self):

View File

@ -304,9 +304,9 @@ def u_username(username, v=None):
listing = get_posts(ids, v=v)
if u.unban_utc:
unban = datetime.fromtimestamp(u.unban_utc).strftime('%c')
#unban = datetime.fromtimestamp(u.unban_utc).strftime('%c')
return {'html': lambda: render_template("userpage.html",
unban=unban,
unban=u.unban_string,
u=u,
v=v,
listing=listing,

View File

@ -67,7 +67,7 @@
<div class="ml-3 w-100">
{% if u.is_banned %}
<h5 style="color:#ff66ac;">BANNED USER{% if u.ban_reason %}: {{u.ban_reason}}{% endif %}</h5>
{% if unban %} <h5 style="color:#ff66ac;">until {{unban}}</h5>{% endif %}
{% if unban %} <h5 style="color:#ff66ac;">{{unban}}</h5>{% endif %}
{% endif %}
<div class="d-flex align-items-center mt-1 mb-2">
@ -282,7 +282,7 @@
<div class="mt-n3 py-3">
{% if u.is_banned %}
<h5 style="color:#ff66ac;">BANNED USER{% if u.ban_reason %}: {{u.ban_reason}}{% endif %}</h5>
{% if unban %} <h5 style="color:#ff66ac;">until {{unban}}</h5>{% endif %}
{% if unban %} <h5 style="color:#ff66ac;">{{unban}}</h5>{% endif %}
{% endif %}
<a class="text-black"><h1 class="h5 d-inline-block" style="color: #{{u.namecolor}}">{{u.username}}</h1></a>