add account status to user list
This commit is contained in:
parent
7d8b518c85
commit
6935a6ae71
3 changed files with 24 additions and 2 deletions
|
|
@ -40,3 +40,9 @@ def append(text, l: list):
|
||||||
l.append(text)
|
l.append(text)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@app.template_filter()
|
||||||
|
def faint_paren(text: str):
|
||||||
|
if not '(' in text:
|
||||||
|
return text
|
||||||
|
t1, t2, t3 = text.partition('(')
|
||||||
|
return Markup('{0} <span class="faint">{1}</span>').format(t1, t2 + t3)
|
||||||
|
|
@ -15,8 +15,9 @@
|
||||||
</p>
|
</p>
|
||||||
<ul class="inline">
|
<ul class="inline">
|
||||||
<li>Age: {{ u.age() }} years old ({{ u.gdpr_birthday.strftime("%B %d, %Y") }})</li>
|
<li>Age: {{ u.age() }} years old ({{ u.gdpr_birthday.strftime("%B %d, %Y") }})</li>
|
||||||
<li>Registered at: {{ u.joined_at }}</li>
|
<li>Registered at: {{ u.joined_at.strftime("%B %d, %Y %H:%M %z") }}</li>
|
||||||
<li>Registered from IP address: {{ u.joined_ip }}</li>
|
<li>Registered from IP address: {{ u.joined_ip }}</li>
|
||||||
|
<li>Status: {{ account_status_string(u) | faint_paren }}</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,21 @@ TARGET_TYPES = {
|
||||||
Comment: REPORT_TARGET_COMMENT
|
Comment: REPORT_TARGET_COMMENT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def account_status_string(u: User):
|
||||||
|
if u.is_active:
|
||||||
|
return 'Active'
|
||||||
|
elif u.banned_at:
|
||||||
|
s = 'Suspended'
|
||||||
|
if u.banned_until:
|
||||||
|
s += f' until {u.banned_until:%b %d, %Y %H:%M}'
|
||||||
|
if u.banned_reason in REPORT_REASON_STRINGS:
|
||||||
|
s += f' ({REPORT_REASON_STRINGS[u.banned_reason]})'
|
||||||
|
return s
|
||||||
|
elif u.is_disabled_by_user:
|
||||||
|
return 'Paused'
|
||||||
|
else:
|
||||||
|
return 'Inactive'
|
||||||
|
|
||||||
def remove_content(target, reason_code: int):
|
def remove_content(target, reason_code: int):
|
||||||
if isinstance(target, Post):
|
if isinstance(target, Post):
|
||||||
target.removed_at = datetime.datetime.now()
|
target.removed_at = datetime.datetime.now()
|
||||||
|
|
@ -153,4 +168,4 @@ def strikes():
|
||||||
def users():
|
def users():
|
||||||
user_list = db.paginate(select(User).order_by(User.joined_at.desc()))
|
user_list = db.paginate(select(User).order_by(User.joined_at.desc()))
|
||||||
return render_template('admin/admin_users.html',
|
return render_template('admin/admin_users.html',
|
||||||
user_list=user_list)
|
user_list=user_list, account_status_string=account_status_string)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue