show number of blockers and blockees in profiles

pull/161/head
Aevann 2023-06-30 00:04:59 +03:00
parent d417fe14f0
commit 4692b558f1
2 changed files with 55 additions and 24 deletions

View File

@ -563,6 +563,16 @@ class User(Base):
def follow_count(self):
return g.db.query(Follow).filter_by(user_id=self.id).count()
@property
@lazy
def block_count(self):
return g.db.query(UserBlock).filter_by(user_id=self.id).count()
@property
@lazy
def blocking_count(self):
return g.db.query(UserBlock).filter_by(target_id=self.id).count()
@property
@lazy
def bio_html_eager(self):
@ -965,7 +975,6 @@ class User(Base):
def applications(self):
return g.db.query(OauthApp).filter_by(author_id=self.id).order_by(OauthApp.id).all()
@property
@lazy
def userblocks(self):

View File

@ -72,11 +72,27 @@
{% if v and (v.id == u.id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']) -%}
<div class="font-weight-bolder mb-2" id="profile--simphate">
<a class="mr-1" href="/@{{u.username}}/views">Profile Views</a> | <a class="mx-1" href="/@{{u.username}}/upvoters">Simps</a> | <a class="mx-1" href="/@{{u.username}}/downvoters">Haters</a> | <a class="mx-1" href="/@{{u.username}}/upvoting">Simps For</a> | <a class="mx-1" href="/@{{u.username}}/downvoting">Hates</a> | <a class="mx-1" href="/@{{u.username}}/voted/posts">Voted</a> | <a class="mx-1" href="/@{{u.username}}/blockers">Blockers</a> | <a class="mx-1" href="/@{{u.username}}/blocking">Blocking</a>
</div>
<a class="mr-1" href="/@{{u.username}}/views">Profile Views</a> |
<a class="mx-1" href="/@{{u.username}}/upvoters">Simps</a> |
<a class="mx-1" href="/@{{u.username}}/downvoters">Haters</a> |
<a class="mx-1" href="/@{{u.username}}/upvoting">Simps For</a> |
<a class="mx-1" href="/@{{u.username}}/downvoting">Hates</a> |
<a class="mx-1" href="/@{{u.username}}/voted/posts">Voted</a>
{%- endif %}
<div class="font-weight-bolder">
<div class="font-weight-bolder mb-1">
<div class="my-2">
{% if PERMS['USER_FOLLOWS_VISIBLE'] == 0 or (v and v.admin_level >= PERMS['USER_FOLLOWS_VISIBLE']) -%}
<a class="mx-1" href="/@{{u.username}}/followers" id="profile--followers">{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}</a> |
<a class="mx-1" href="/@{{u.username}}/following" id="profile--following">follows {{u.follow_count}} user{{'s' if u.follow_count != 1 else ''}}</a> |
<a class="mx-1" href="/@{{u.username}}/blockers" id="profile--blockers">{{u.blocking_count}} blocker{{'s' if u.blocking_count != 1 else ''}}</a> |
<a class="mx-1" href="/@{{u.username}}/blocking" id="profile--blocking">blocks {{u.block_count}} user{{'s' if u.block_count != 1 else ''}}</a>
{%- endif %}
</div>
<span id="profile-coins-amount">{{u.coins}}</span>
<img loading="lazy" alt="coins" class="ml-1 mb-1 mr-2" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Coins" height="20" src="{{'coins.webp' | asset_siteimg}}">
@ -84,20 +100,15 @@
<span id="profile-bux-amount">{{u.marseybux}}</span>
<img loading="lazy" alt="marseybux" class="ml-1 mb-1 mr-2" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Marseybux" height="20" width="46" src="{{SITE_FULL_IMAGES}}/i/marseybux.webp?x=6">
{% endif %}
{% if PERMS['USER_FOLLOWS_VISIBLE'] == 0 or (v and v.admin_level >= PERMS['USER_FOLLOWS_VISIBLE']) -%}
<a class="mr-2" href="/@{{u.username}}/followers" id="profile--followers">{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}</a>
<a class="mr-2" href="/@{{u.username}}/following" id="profile--following">follows {{u.follow_count}} user{{'s' if u.follow_count != 1 else ''}}</a>
{%- endif %}
<span id="profile--joined">joined <span id="profile--joined--time" data-bs-toggle="tooltip" data-bs-placement="bottom" data-nonce="{{g.nonce}}" data-onmouseover="timestamp(this, '{{u.created_utc}}')">{{u.created_date}}</span></span>
{% if v and v.admin_level >= PERMS['VIEW_LAST_ACTIVE'] -%}
<span id="profile--lastactive" class="ml-2">last active <span id="profile--lastactive--time" data-bs-toggle="tooltip" data-bs-placement="bottom" data-nonce="{{g.nonce}}" data-onmouseover="timestamp(this, '{{u.last_active}}')">{{u.last_active_date}}</span></span>
{%- endif %}
</div>
<span id="profile--joined">joined <span id="profile--joined--time" data-bs-toggle="tooltip" data-bs-placement="bottom" data-nonce="{{g.nonce}}" data-onmouseover="timestamp(this, '{{u.created_utc}}')">{{u.created_date}}</span></span>
{% if v and v.admin_level >= PERMS['VIEW_LAST_ACTIVE'] -%}
<span id="profile--lastactive" class="ml-2">last active <span id="profile--lastactive--time" data-bs-toggle="tooltip" data-bs-placement="bottom" data-nonce="{{g.nonce}}" data-onmouseover="timestamp(this, '{{u.last_active}}')">{{u.last_active_date}}</span></span>
{%- endif %}
</div>
{% if FEATURES['USERS_PROFILE_BODYTEXT'] -%}
{% if u.bio_html and u.can_see_my_shit %}
<div class="text-muted font-weight-bolder mt-1" id="profile--bio">{{u.bio_html | safe}}</div>
@ -354,11 +365,28 @@
{% if v and (v.id == u.id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']) -%}
<div class="font-weight-bolder mb-2" id="profile-mobile--simphate">
<a class="mr-1" href="/@{{u.username}}/views">Profile Views</a> | <a class="mx-1" href="/@{{u.username}}/upvoters">Simps</a> | <a class="mx-1" href="/@{{u.username}}/downvoters">Haters</a> | <a class="mx-1" href="/@{{u.username}}/upvoting">Simps For</a> | <a class="mx-1" href="/@{{u.username}}/downvoting">Hates</a> | <a class="mx-1" href="/@{{u.username}}/voted/posts">Voted</a> | <a class="mx-1" href="/@{{u.username}}/blockers">Blockers</a> | <a class="mx-1" href="/@{{u.username}}/blocking">Blocking</a>
<a class="mr-1" href="/@{{u.username}}/views">Profile Views</a> |
<a class="mx-1" href="/@{{u.username}}/upvoters">Simps</a> |
<a class="mx-1" href="/@{{u.username}}/downvoters">Haters</a> |
<a class="mx-1" href="/@{{u.username}}/upvoting">Simps For</a> |
<a class="mx-1" href="/@{{u.username}}/downvoting">Hates</a> |
<a class="mx-1" href="/@{{u.username}}/voted/posts">Voted</a>
</div>
{%- endif %}
<div class="font-weight-normal">
<div class="font-weight-bold">
<div class="mb-2">
{% if PERMS['USER_FOLLOWS_VISIBLE'] == 0 or (v and v.admin_level >= PERMS['USER_FOLLOWS_VISIBLE']) -%}
<a href="/@{{u.username}}/followers" class="font-weight-bolder mx-1" id="profile-mobile--followers">{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}</a> |
<a href="/@{{u.username}}/following" class="font-weight-bolder mx-1" id="profile-mobile--following"> follows {{u.follow_count}} user{{'s' if u.follow_count != 1 else ''}}</a> |
<a class="mx-1" href="/@{{u.username}}/blockers" id="profile--blockers">{{u.blocking_count}} blocker{{'s' if u.blocking_count != 1 else ''}}</a> |
<a class="mx-1" href="/@{{u.username}}/blocking" id="profile--blocking">blocks {{u.block_count}} user{{'s' if u.block_count != 1 else ''}}</a>
{%- endif %}
</div>
<span id="profile-coins-amount-mobile" class="font-weight-bold">{{u.coins}}</span>
<img loading="lazy" alt="coins" class="ml-1 mb-1 mr-2" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Coins" height="15" src="{{'coins.webp' | asset_siteimg}}">
@ -367,12 +395,6 @@
<img loading="lazy" alt="marseybux" class="ml-1 mb-1 mr-2" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Marseybux" height="15" width="35" src="{{SITE_FULL_IMAGES}}/i/marseybux.webp?x=6">
{% endif %}
{% if PERMS['USER_FOLLOWS_VISIBLE'] == 0 or (v and v.admin_level >= PERMS['USER_FOLLOWS_VISIBLE']) -%}
<a href="/@{{u.username}}/followers" class="font-weight-bold mr-2" id="profile-mobile--followers">{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}</a>
<a href="/@{{u.username}}/following" class="font-weight-bold mr-2" id="profile-mobile--following" style="display:block">follows {{u.follow_count}} user{{'s' if u.follow_count != 1 else ''}}</a>
{%- endif %}
<br><span id="profile-mobile--joined">joined <span id="profile-mobile--joined--time" data-bs-toggle="tooltip" data-bs-placement="bottom" data-nonce="{{g.nonce}}" data-onmouseover="timestamp(this, '{{u.created_utc}}')" class="font-weight-bold">{{u.created_date}}</span></span>
{% if v and v.admin_level >= PERMS['VIEW_LAST_ACTIVE'] -%}