[#19] hide autocomment for user without access to the issue

This commit is contained in:
Alexander Machehin 2013-04-10 01:26:27 +06:00
parent 5760eac5f9
commit c8084cc618
3 changed files with 40 additions and 30 deletions

View File

@ -3,7 +3,7 @@ class CommentPresenter < ApplicationPresenter
include PullRequestHelper
attr_accessor :comment, :options
attr_reader :header, :image, :date, :caption, :content, :buttons, :is_reference_to_issue
attr_reader :header, :image, :date, :caption, :content, :buttons, :is_reference_to_issue, :item
def initialize(comment, opts = {})
@is_reference_to_issue = !!(comment.automatic && comment.created_from_issue_id) # is it reference issue from another issue
@ -110,4 +110,8 @@ class CommentPresenter < ApplicationPresenter
pull_status_label @referenced_issue
end.html_safe
end
def item
@comment
end
end

View File

@ -3,16 +3,17 @@ class GitPresenters::CommitAsMessagePresenter < ApplicationPresenter
include CommitHelper
attr_accessor :commit
attr_reader :header, :image, :date, :caption, :content, :expandable, :is_reference_to_issue, :committer
attr_reader :header, :image, :date, :caption, :content, :expandable,
:is_reference_to_issue, :committer, :item
def initialize(commit, opts = {})
comment = opts[:comment]
@is_reference_to_issue = !!comment # is it reference issue from commit
@project = if comment
Project.where(:id => opts[:comment].data[:from_project_id]).first
else
opts[:project]
end
Project.where(:id => comment.data[:from_project_id]).first
else
opts[:project]
end
commit = commit || @project.repo.commit(comment.created_from_commit_hash.to_s(16)) if @project
if @project && commit
@ -76,6 +77,10 @@ class GitPresenters::CommitAsMessagePresenter < ApplicationPresenter
false
end
def item
@commit
end
protected
def committer_link

View File

@ -1,27 +1,28 @@
.activity{:id => presenter.comment_id? ? presenter.comment_anchor : ''}
.top
- if presenter.buttons?
%span.buttons= raw presenter.buttons.join(' | ').html_safe
.image
%img{:alt => "avatar", :src => presenter.image}
.text
-#.imaged move up a line.
%span.name= presenter.header
.both
%span.date= presenter.date
.both
- if presenter.caption?
%span.subject= presenter.caption
- if presenter.expandable? and presenter.content?
%span.data-expander.collapsed{:id => "expand#{item_no}"} &nbsp;
-if !presenter.is_reference_to_issue || can?(:show, presenter.item)
.activity{:id => presenter.comment_id? ? presenter.comment_anchor : ''}
.top
- if presenter.buttons?
%span.buttons= raw presenter.buttons.join(' | ').html_safe
.image
%img{:alt => "avatar", :src => presenter.image}
.text
-#.imaged move up a line.
%span.name= presenter.header
.both
.both
- if presenter.content?
%div
=presenter.issue_referenced_state if presenter.issue_referenced_state?
.fulltext{:class => "#{presenter.expandable? ? "hidden" : ''} #{presenter.caption? ? "" : "alone"}",
:id => presenter.expandable? ? "content-expand#{item_no}" : ''}
.md_and_cm{:class => presenter.is_reference_to_issue ? '' : 'cm-s-default'}
=presenter.is_reference_to_issue ? presenter.content : markdown(presenter.content)
%span.date= presenter.date
.both
- if presenter.caption?
%span.subject= presenter.caption
- if presenter.expandable? and presenter.content?
%span.data-expander.collapsed{:id => "expand#{item_no}"} &nbsp;
.both
.both
- if presenter.content?
%div
=presenter.issue_referenced_state if presenter.issue_referenced_state?
.fulltext{:class => "#{presenter.expandable? ? "hidden" : ''} #{presenter.caption? ? "" : "alone"}",
:id => presenter.expandable? ? "content-expand#{item_no}" : ''}
.md_and_cm{:class => presenter.is_reference_to_issue ? '' : 'cm-s-default'}
=presenter.is_reference_to_issue ? presenter.content : markdown(presenter.content)
.both