mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Merge pull request #2591 from BenLubar/benlubar-edit-history-public
add profile option for edit history visibility
This commit is contained in:
commit
e7e70d14da
8 changed files with 30 additions and 3 deletions
|
@ -167,6 +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}}
|
||||
{{#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"}}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -778,6 +778,7 @@ end
|
|||
# registration_ip_address :inet
|
||||
# last_redirected_to_top_at :datetime
|
||||
# disable_jump_reply :boolean default(FALSE), not null
|
||||
# edit_history_public :boolean default(FALSE), not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -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
|
||||
|
@ -236,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
|
||||
|
|
|
@ -15,7 +15,8 @@ class UserUpdater
|
|||
:enable_quoting,
|
||||
:dynamic_favicon,
|
||||
:mailing_list_mode,
|
||||
:disable_jump_reply
|
||||
:disable_jump_reply,
|
||||
:edit_history_public
|
||||
]
|
||||
|
||||
PROFILE_ATTR = [
|
||||
|
|
|
@ -271,6 +271,7 @@ en:
|
|||
notifications: "Notifications"
|
||||
disable_jump_reply: "Don't jump to your new post after replying"
|
||||
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"
|
||||
enable_quoting: "Enable quote reply for highlighted text"
|
||||
change: "change"
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddEditHistoryPublicToUsers < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :edit_history_public, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
|
@ -145,7 +145,7 @@ module PostGuardian
|
|||
return false unless post
|
||||
|
||||
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
|
||||
|
||||
authenticated? &&
|
||||
|
|
|
@ -404,6 +404,12 @@ describe Guardian do
|
|||
it 'is true when logged in' do
|
||||
Guardian.new(Fabricate(:user)).can_see?(post_revision).should == true
|
||||
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
|
||||
|
||||
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
|
||||
Guardian.new(Fabricate(:leader)).can_see?(post_revision).should == false
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue