FEATURE: Site Setting to hide suspension reason on the public profile
This commit is contained in:
parent
d7c37d9369
commit
561fa7d0cd
|
@ -4,7 +4,12 @@
|
|||
{{text-field value=duration maxlength="5" autofocus="autofocus"}}
|
||||
{{i18n 'admin.user.suspend_duration_units'}}<br/>
|
||||
<br/>
|
||||
{{{i18n 'admin.user.suspend_reason_label'}}}<br/>
|
||||
{{#if siteSettings.hide_suspension_reasons}}
|
||||
{{{i18n 'admin.user.suspend_reason_hidden_label'}}}<br/>
|
||||
{{else}}
|
||||
{{{i18n 'admin.user.suspend_reason_label'}}}<br/>
|
||||
{{/if}}
|
||||
|
||||
<br/>
|
||||
{{text-field value=reason class="span8"}}
|
||||
</form>
|
||||
|
|
|
@ -84,8 +84,10 @@
|
|||
{{#if model.isSuspended}}
|
||||
<div class='suspended'>
|
||||
{{d-icon "ban"}}
|
||||
<b>{{i18n 'user.suspended_notice' date=model.suspendedTillDate}}</b><br/>
|
||||
<b>{{i18n 'user.suspended_reason'}}</b> {{model.suspend_reason}}
|
||||
<b>{{i18n 'user.suspended_notice' date=model.suspendedTillDate}}</b><br>
|
||||
{{#if model.suspend_reason}}
|
||||
<b>{{i18n 'user.suspended_reason'}}</b> {{model.suspend_reason}}
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if isNotSuspendedOrIsStaff}}
|
||||
|
|
|
@ -251,7 +251,7 @@ class UserSerializer < BasicUserSerializer
|
|||
end
|
||||
|
||||
def include_suspend_reason?
|
||||
object.suspended?
|
||||
scope.can_see_suspension_reason?(object) && object.suspended?
|
||||
end
|
||||
|
||||
def include_suspended_till?
|
||||
|
|
|
@ -3266,6 +3266,7 @@ en:
|
|||
suspend_duration: "How long will the user be suspended for?"
|
||||
suspend_duration_units: "(days)"
|
||||
suspend_reason_label: "Why are you suspending? This text <b>will be visible to everyone</b> on this user's profile page, and will be shown to the user when they try to log in. Keep it short."
|
||||
suspend_reason_hidden_label: "Why are you suspending? This text will be shown to the user when they try to log in. Keep it short."
|
||||
suspend_reason: "Reason"
|
||||
suspended_by: "Suspended by"
|
||||
delete_all_posts: "Delete all posts"
|
||||
|
|
|
@ -1441,6 +1441,7 @@ en:
|
|||
|
||||
hide_user_profiles_from_public: "Disable user cards, user profiles and user directory for anonymous users."
|
||||
|
||||
hide_suspension_reasons: "Don't display suspension reasons publically on user profiles."
|
||||
user_website_domains_whitelist: "User website will be verified against these domains. Pipe-delimited list."
|
||||
|
||||
allow_profile_backgrounds: "Allow users to upload profile backgrounds."
|
||||
|
|
|
@ -422,6 +422,9 @@ users:
|
|||
user_website_domains_whitelist:
|
||||
default: ''
|
||||
type: list
|
||||
hide_suspension_reasons:
|
||||
default: false
|
||||
client: true
|
||||
|
||||
groups:
|
||||
enable_group_directory:
|
||||
|
|
|
@ -67,4 +67,9 @@ module UserGuardian
|
|||
user && is_staff?
|
||||
end
|
||||
|
||||
def can_see_suspension_reason?(user)
|
||||
return true unless SiteSetting.hide_suspension_reasons?
|
||||
user == @user || is_staff?
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -2541,4 +2541,32 @@ describe Guardian do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "suspension reasons" do
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
||||
it "will be shown by default" do
|
||||
expect(Guardian.new.can_see_suspension_reason?(user)).to eq(true)
|
||||
end
|
||||
|
||||
context "with hide suspension reason enabled" do
|
||||
let(:moderator) { Fabricate(:moderator) }
|
||||
|
||||
before do
|
||||
SiteSetting.hide_suspension_reasons = true
|
||||
end
|
||||
|
||||
it "will not be shown to anonymous users" do
|
||||
expect(Guardian.new.can_see_suspension_reason?(user)).to eq(false)
|
||||
end
|
||||
|
||||
it "users can see their own suspensions" do
|
||||
expect(Guardian.new(user).can_see_suspension_reason?(user)).to eq(true)
|
||||
end
|
||||
|
||||
it "staff can see suspensions" do
|
||||
expect(Guardian.new(moderator).can_see_suspension_reason?(user)).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue