This commit is contained in:
fireworks88 2021-07-28 17:37:38 +02:00
parent 1b5a1f9698
commit b435e6b398
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):