make sure the post/comment for which someone was banned is linked everywhere (for convenience)

remotes/1693045480750635534/spooky-22
Aevann1 2022-05-30 04:55:51 +02:00
parent 739152747f
commit aff30db1fe
3 changed files with 14 additions and 16 deletions

View File

@ -259,13 +259,6 @@ class User(Base):
def age(self):
return int(time.time()) - self.created_utc
@property
@lazy
def ban_reason_link(self):
if self.ban_reason:
if self.ban_reason.startswith("/post/"): return self.ban_reason.split(None, 1)[0]
if self.ban_reason.startswith("/comment/"): return self.ban_reason.split(None, 1)[0] + "?context=8#context"
@property
@lazy
def alts_unique(self):

View File

@ -1123,16 +1123,19 @@ def ban_user(user_id, v):
days = float(request.values.get("days")) if request.values.get('days') else 0
reason = request.values.get("reason", "").strip()[:256]
passed_reason = filter_emojis_only(reason)
reason = filter_emojis_only(reason)
if len(passed_reason) > 256: passed_reason = reason
if reason.startswith("/") and '\\' not in reason:
reason = f'<a href="{reason.split()[0]}">{reason}</a>'
user.ban(admin=v, reason=passed_reason, days=days)
if len(reason) > 256: reason = reason
user.ban(admin=v, reason=reason, days=days)
if request.values.get("alts"):
for x in user.alts:
if x.admin_level: break
x.ban(admin=v, reason=passed_reason, days=days)
x.ban(admin=v, reason=reason, days=days)
if days:
if reason: text = f"@{v.username} has banned you for **{days}** days for the following reason:\n\n> {reason}"

View File

@ -44,12 +44,14 @@
</div>
<div id="profilestuff" class="ml-3 w-100">
{% if u.is_suspended %}
<h5 class="text-primary" id="profile--banned">BANNED USER{% if u.ban_reason %}:
{% if u.ban_reason_link %}<a href="{{u.ban_reason_link}}"><i class="fas fa-link"></i>{% endif %}
<h5 class="text-primary" id="profile--banned">BANNED USER
{% if u.ban_reason %}:
{{u.ban_reason | safe}}
{% if u.ban_reason_link %}</a>{% endif %}
{% endif %}</h5>
{% if u.unban_utc %}<h5 class="text-primary" id="profile--unban">{{u.unban_string}}</h5>{% endif %}
{% endif %}
</h5>
{% if u.unban_utc %}
<h5 class="text-primary" id="profile--unban">{{u.unban_string}}</h5>
{% endif %}
{% endif %}
<div class="d-flex align-items-center mt-1 mb-2">
<h1 class="font-weight-bolder h3 mb-0" id="profile--name" style="color: #{{u.namecolor}}"><span {% if u.patron %}class="patron" style="background-color:#{{u.namecolor}}"{% endif %}>{{u.username}}</span></h1>