Merge pull request #2591 from BenLubar/benlubar-edit-history-public

add profile option for edit history visibility
This commit is contained in:
Sam 2014-07-30 14:09:10 +10:00
commit e7e70d14da
8 changed files with 30 additions and 3 deletions

View File

@ -167,6 +167,9 @@
{{preference-checkbox labelKey="user.enable_quoting" checked=enable_quoting}} {{preference-checkbox labelKey="user.enable_quoting" checked=enable_quoting}}
{{preference-checkbox labelKey="user.dynamic_favicon" checked=dynamic_favicon}} {{preference-checkbox labelKey="user.dynamic_favicon" checked=dynamic_favicon}}
{{preference-checkbox labelKey="user.disable_jump_reply" checked=disable_jump_reply}} {{preference-checkbox labelKey="user.disable_jump_reply" checked=disable_jump_reply}}
{{#unless Discourse.SiteSettings.edit_history_available_to_public}}
{{preference-checkbox labelKey="user.edit_history_public" checked=edit_history_public}}
{{/unless}}
{{plugin-outlet "user_custom_preferences"}} {{plugin-outlet "user_custom_preferences"}}
</div> </div>

View File

@ -778,6 +778,7 @@ end
# registration_ip_address :inet # registration_ip_address :inet
# last_redirected_to_top_at :datetime # last_redirected_to_top_at :datetime
# disable_jump_reply :boolean default(FALSE), not null # disable_jump_reply :boolean default(FALSE), not null
# edit_history_public :boolean default(FALSE), not null
# #
# Indexes # Indexes
# #

View File

@ -43,7 +43,8 @@ class UserSerializer < BasicUserSerializer
:suspended_till, :suspended_till,
:uploaded_avatar_id, :uploaded_avatar_id,
:badge_count, :badge_count,
:has_title_badges :has_title_badges,
:edit_history_public
has_one :invited_by, embed: :object, serializer: BasicUserSerializer has_one :invited_by, embed: :object, serializer: BasicUserSerializer
has_many :custom_groups, embed: :object, serializer: BasicGroupSerializer has_many :custom_groups, embed: :object, serializer: BasicGroupSerializer
@ -236,4 +237,7 @@ class UserSerializer < BasicUserSerializer
object.badges.where(allow_title: true).count > 0 object.badges.where(allow_title: true).count > 0
end end
def include_edit_history_public?
can_edit && !SiteSetting.edit_history_visible_to_public
end
end end

View File

@ -15,7 +15,8 @@ class UserUpdater
:enable_quoting, :enable_quoting,
:dynamic_favicon, :dynamic_favicon,
:mailing_list_mode, :mailing_list_mode,
:disable_jump_reply :disable_jump_reply,
:edit_history_public
] ]
PROFILE_ATTR = [ PROFILE_ATTR = [

View File

@ -271,6 +271,7 @@ en:
notifications: "Notifications" notifications: "Notifications"
disable_jump_reply: "Don't jump to your new post after replying" disable_jump_reply: "Don't jump to your new post after replying"
dynamic_favicon: "Show incoming message notifications on favicon (experimental)" dynamic_favicon: "Show incoming message notifications on favicon (experimental)"
edit_history_public: "Let other users view my post revisions"
external_links_in_new_tab: "Open all external links in a new tab" external_links_in_new_tab: "Open all external links in a new tab"
enable_quoting: "Enable quote reply for highlighted text" enable_quoting: "Enable quote reply for highlighted text"
change: "change" change: "change"

View File

@ -0,0 +1,5 @@
class AddEditHistoryPublicToUsers < ActiveRecord::Migration
def change
add_column :users, :edit_history_public, :boolean, default: false, null: false
end
end

View File

@ -145,7 +145,7 @@ module PostGuardian
return false unless post return false unless post
if !post.hidden if !post.hidden
return true if post.wiki || SiteSetting.edit_history_visible_to_public return true if post.wiki || SiteSetting.edit_history_visible_to_public || post.user.try(:edit_history_public)
end end
authenticated? && authenticated? &&

View File

@ -404,6 +404,12 @@ describe Guardian do
it 'is true when logged in' do it 'is true when logged in' do
Guardian.new(Fabricate(:user)).can_see?(post_revision).should == true Guardian.new(Fabricate(:user)).can_see?(post_revision).should == true
end end
it 'is true if the author has public edit history' do
public_post_revision = Fabricate(:post_revision)
public_post_revision.post.user.edit_history_public = true
Guardian.new.can_see?(public_post_revision).should == true
end
end end
context 'edit_history_visible_to_public is false' do context 'edit_history_visible_to_public is false' do
@ -421,6 +427,12 @@ describe Guardian do
it 'is false for trust level lower than 4' do it 'is false for trust level lower than 4' do
Guardian.new(Fabricate(:leader)).can_see?(post_revision).should == false Guardian.new(Fabricate(:leader)).can_see?(post_revision).should == false
end end
it 'is true if the author has public edit history' do
public_post_revision = Fabricate(:post_revision)
public_post_revision.post.user.edit_history_public = true
Guardian.new.can_see?(public_post_revision).should == true
end
end end
end end
end end