Commit 0b3cda2459ae80d8974c0a8829376e57e5c066ad

Authored by Sergey Nartimov
1 parent 1c661cdd
Exists in master and in 1 other branch production

extract Problem#comments_allowed? method

app/models/problem.rb
@@ -57,6 +57,10 @@ class Problem @@ -57,6 +57,10 @@ class Problem
57 Notice.for_errs(errs).ordered 57 Notice.for_errs(errs).ordered
58 end 58 end
59 59
  60 + def comments_allowed?
  61 + Errbit::Config.allow_comments_with_issue_tracker || !app.issue_tracker_configured?
  62 + end
  63 +
60 def resolve! 64 def resolve!
61 self.update_attributes!(:resolved => true, :resolved_at => Time.now) 65 self.update_attributes!(:resolved => true, :resolved_at => Time.now)
62 end 66 end
app/views/problems/show.html.haml
@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
20 %br 20 %br
21 = render "issue_tracker_links" 21 = render "issue_tracker_links"
22 22
23 -- if Errbit::Config.allow_comments_with_issue_tracker || !@app.issue_tracker_configured? || @problem.comments.any? 23 +- if @problem.comments_allowed? || @problem.comments.any?
24 - content_for :comments do 24 - content_for :comments do
25 %h3 Comments 25 %h3 Comments
26 - @problem.comments.each do |comment| 26 - @problem.comments.each do |comment|
@@ -41,7 +41,7 @@ @@ -41,7 +41,7 @@
41 %span.delete= link_to '✘'.html_safe, app_problem_comment_path(@app, @problem, comment), :method => :delete, :data => { :confirm => "Are sure you don't need this comment?" }, :class => "destroy-comment" 41 %span.delete= link_to '✘'.html_safe, app_problem_comment_path(@app, @problem, comment), :method => :delete, :data => { :confirm => "Are sure you don't need this comment?" }, :class => "destroy-comment"
42 %tr 42 %tr
43 %td= simple_format comment.body 43 %td= simple_format comment.body
44 - - if Errbit::Config.allow_comments_with_issue_tracker || !@app.issue_tracker_configured? 44 + - if @problem.comments_allowed?
45 = form_for @comment, :url => app_problem_comments_path(@app, @problem) do |comment_form| 45 = form_for @comment, :url => app_problem_comments_path(@app, @problem) do |comment_form|
46 %p Add a comment 46 %p Add a comment
47 = comment_form.text_area :body, :style => "width: 420px; height: 80px;" 47 = comment_form.text_area :body, :style => "width: 420px; height: 80px;"