From ac8c2e1e077aba40d11cbfd31b62f2d0cd46af9b Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Sun, 27 Jul 2014 12:12:36 -0500 Subject: [PATCH] discourse#2591 --- .../discourse/templates/user/preferences.js.handlebars | 4 ++-- app/serializers/user_serializer.rb | 9 ++++++--- lib/guardian/post_guardian.rb | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars b/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars index ca7a8213f55..f5406e2dad2 100644 --- a/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars +++ b/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars @@ -167,9 +167,9 @@ {{preference-checkbox labelKey="user.enable_quoting" checked=enable_quoting}} {{preference-checkbox labelKey="user.dynamic_favicon" checked=dynamic_favicon}} {{preference-checkbox labelKey="user.disable_jump_reply" checked=disable_jump_reply}} - {{#if !Discourse.SiteSettings.edit_history_available_to_public}} + {{#unless Discourse.SiteSettings.edit_history_available_to_public}} {{preference-checkbox labelKey="user.edit_history_public" checked=edit_history_public}} - {{/if}} + {{/unless}} {{plugin-outlet "user_custom_preferences"}} diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb index 43237b55a3e..b2bde1321a5 100644 --- a/app/serializers/user_serializer.rb +++ b/app/serializers/user_serializer.rb @@ -43,7 +43,8 @@ class UserSerializer < BasicUserSerializer :suspended_till, :uploaded_avatar_id, :badge_count, - :has_title_badges + :has_title_badges, + :edit_history_public has_one :invited_by, embed: :object, serializer: BasicUserSerializer has_many :custom_groups, embed: :object, serializer: BasicGroupSerializer @@ -77,8 +78,7 @@ class UserSerializer < BasicUserSerializer :gravatar_avatar_upload_id, :custom_avatar_upload_id, :custom_fields, - :has_title_badges, - :edit_history_public + :has_title_badges ### ### ATTRIBUTES @@ -237,4 +237,7 @@ class UserSerializer < BasicUserSerializer object.badges.where(allow_title: true).count > 0 end + def include_edit_history_public? + can_edit && !SiteSetting.edit_history_visible_to_public + end end diff --git a/lib/guardian/post_guardian.rb b/lib/guardian/post_guardian.rb index 244afbd58c8..d40f17d806d 100644 --- a/lib/guardian/post_guardian.rb +++ b/lib/guardian/post_guardian.rb @@ -137,7 +137,7 @@ module PostGuardian return false unless post if !post.hidden - return true if post.wiki || SiteSetting.edit_history_visible_to_public || post.user.edit_history_public + return true if post.wiki || SiteSetting.edit_history_visible_to_public || post.user.try(:edit_history_public) end authenticated? &&