dedup april fools code

master
Aevann 2024-04-01 21:58:29 +02:00
parent d105d8b5c5
commit 678477b819
5 changed files with 6 additions and 15 deletions

View File

@ -341,7 +341,7 @@ class Comment(Base):
@lazy
def author_name(self):
if self.ghost and not (hasattr(g, 'v') and g.v and self.id == g.v.id): return '👻'
return self.author.user_name
return self.author.switched.user_name
@property
@lazy

View File

@ -172,7 +172,7 @@ class Post(Base):
@lazy
def author_name(self):
if self.ghost and not (hasattr(g, 'v') and g.v and self.id == g.v.id): return '👻'
return self.author.user_name
return self.author.switched.user_name
@property
@lazy

View File

@ -1314,15 +1314,6 @@ class User(Base):
@property
@lazy
def user_name(self):
if self.id != 2249 and not (has_request_context() and request.path == '/notifications/modmail'):
random.seed(self.id)
uid = random.choice(USER_IDS)
random.seed()
to_load = [User.username]
if SITE_NAME == 'rDrama':
to_load.append(User.earlylife)
self = g.db.query(User).options(load_only(*to_load)).filter_by(id=uid).one()
if self.earlylife:
expiry = int(self.earlylife - time.time())
if expiry > 86400:
@ -1336,7 +1327,7 @@ class User(Base):
@property
@lazy
def switched(self):
if self.id == 2249 or request.path == '/notifications/modmail':
if self.id == 2249 or (has_request_context() and request.path == '/notifications/modmail'):
return self
random.seed(self.id)

View File

@ -8,7 +8,7 @@
<img class="profile-pic-20-hat hat" loading="lazy" src="{{user.hat_active(v)[0]}}?x=8" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{user.hat_active(v)[1]}}">
{%- endif %}
</div>
<span {% if user.patron %}class="patron" style="background-color:#{{user.name_color}}"{% endif %} {% if user.pride_username(v) %}pride_username{% endif %}>{{user.username}}</span>
<span {% if user.patron %}class="patron" style="background-color:#{{user.name_color}}"{% endif %} {% if user.pride_username(v) %}pride_username{% endif %}>{{user.user_name}}</span>
</a>
{% endif %}
{% endif %}

View File

@ -28,7 +28,7 @@
<div id="profilestuff" class="ml-3 w-100">
{{userpage_admintools.userBanBlock('desktop')}}
<div class="d-flex align-items-center mt-1 mb-2">
<h3 class="font-weight-bolder my-0 mr-2" id="profile--name" style="color: #{{u.name_color}}"><span {% if u.patron %}class="patron" style="background-color:#{{u.name_color}}"{% endif %} {% if u.pride_username(v) %}pride_username{% endif %}>{{u.username}}</span></h3>
<h3 class="font-weight-bolder my-0 mr-2" id="profile--name" style="color: #{{u.name_color}}"><span {% if u.patron %}class="patron" style="background-color:#{{u.name_color}}"{% endif %} {% if u.pride_username(v) %}pride_username{% endif %}>{{u.user_name}}</span></h3>
{% if can_see(v, u) %}
{% set ns.og_usernames = 'Reserved Usernames:' %}
@ -355,7 +355,7 @@
</div>
<div class="mt-n3 py-3">
{{userpage_admintools.userBanBlock('mobile')}}
<h5 class=" d-inline-block" id="profile-mobile--name" style="color: #{{u.name_color}}"><span {% if u.patron %}class="patron" style="background-color:#{{u.name_color}}"{% endif %} {% if u.pride_username(v) %}pride_username{% endif %}>{{u.username}}</span></h5>
<h5 class=" d-inline-block" id="profile-mobile--name" style="color: #{{u.name_color}}"><span {% if u.patron %}class="patron" style="background-color:#{{u.name_color}}"{% endif %} {% if u.pride_username(v) %}pride_username{% endif %}>{{u.user_name}}</span></h5>
{% if can_see(v, u) and ns.og_usernames != 'Reserved Usernames:' %}
<span id="profile-mobile--origname">