mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 14:07:30 +08:00
DEV: Allow plugins to hide user stats by new guardian method (#9772)
This commit is contained in:

committed by
GitHub

parent
87b9488137
commit
bec6bace53
@ -1,5 +1,6 @@
|
||||
{{#d-section pageClass="user-summary" tagName=""}}
|
||||
<div class="user-content">
|
||||
{{#if model.can_see_summary_stats}}
|
||||
<div class="top-section stats-section">
|
||||
<h3 class="stats-title">{{i18n "user.summary.stats"}}</h3>
|
||||
<ul>
|
||||
@ -48,6 +49,7 @@
|
||||
{{plugin-outlet name="user-summary-stat" tagName="" connectorTagName="li" args=(hash model=model)}}
|
||||
</ul>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="top-section">
|
||||
{{#user-summary-section title="top_replies" class="replies-section pull-left"}}
|
||||
|
@ -112,6 +112,10 @@ class UserSummary
|
||||
@user.id
|
||||
end
|
||||
|
||||
def user
|
||||
@user
|
||||
end
|
||||
|
||||
def user_stat
|
||||
@user.user_stat
|
||||
end
|
||||
|
@ -56,7 +56,12 @@ class UserSummarySerializer < ApplicationSerializer
|
||||
:post_count,
|
||||
:time_read,
|
||||
:recent_time_read,
|
||||
:bookmark_count
|
||||
:bookmark_count,
|
||||
:can_see_summary_stats
|
||||
|
||||
def can_see_summary_stats
|
||||
scope.can_see_summary_stats?(object.user)
|
||||
end
|
||||
|
||||
def include_badges?
|
||||
SiteSetting.enable_badges
|
||||
@ -73,4 +78,40 @@ class UserSummarySerializer < ApplicationSerializer
|
||||
def recent_time_read
|
||||
object.recent_time_read
|
||||
end
|
||||
|
||||
def include_likes_given?
|
||||
can_see_summary_stats
|
||||
end
|
||||
|
||||
def include_likes_received?
|
||||
can_see_summary_stats
|
||||
end
|
||||
|
||||
def include_topics_entered?
|
||||
can_see_summary_stats
|
||||
end
|
||||
|
||||
def include_posts_read_count?
|
||||
can_see_summary_stats
|
||||
end
|
||||
|
||||
def include_days_visited?
|
||||
can_see_summary_stats
|
||||
end
|
||||
|
||||
def include_topic_count?
|
||||
can_see_summary_stats
|
||||
end
|
||||
|
||||
def include_post_count?
|
||||
can_see_summary_stats
|
||||
end
|
||||
|
||||
def include_time_read?
|
||||
can_see_summary_stats
|
||||
end
|
||||
|
||||
def include_recent_time_read?
|
||||
can_see_summary_stats
|
||||
end
|
||||
end
|
||||
|
@ -154,4 +154,8 @@ module UserGuardian
|
||||
.exists?
|
||||
)
|
||||
end
|
||||
|
||||
def can_see_summary_stats?(target_user)
|
||||
true
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user