review = get_review(params[:id])
review.transaction do
comment = params[:comment] || request.raw_post
- if review.isClosed?
+ if review.closed?
raise "Closed review can not be commented."
end
raise "Comment must be provided." unless comment && !comment.blank?
review = get_review(params[:id])
review.transaction do
assignee = params[:assignee]
- if !review.isOpen? && !review.isReopened?
+ if !review.open? && !review.reopened?
raise "Only open review can be reassigned."
end
if assignee.blank?
review.transaction do
resolution = params[:resolution]
comment = params[:comment] || request.raw_post
- if !review.isOpen? && !review.isReopened?
+ if !review.open? && !review.reopened?
raise "Only open review can be resolved."
end
if resolution == Review::RESOLUTION_FALSE_POSITIVE
review = get_review(params[:id])
review.transaction do
comment = params[:comment] || request.raw_post
- if !review.isResolved?
+ if !review.resolved?
raise "Only resolved review can be reopened."
end
if review.resolution == Review::RESOLUTION_FALSE_POSITIVE
SECTION=Navigation::SECTION_HOME
- verify :method => :post,
+ verify :method => :post,
:only => [:assign, :flag_as_false_positive, :save_comment, :delete_comment, :change_status,
- :violation_assign, :violation_flag_as_false_positive,:violation_save_comment, :violation_delete_comment, :violation_change_status],
+ :violation_assign, :violation_flag_as_false_positive, :violation_save_comment, :violation_delete_comment, :violation_change_status],
:redirect_to => {:action => :error_not_post}
helper SourceHelper, UsersHelper
init_params()
search_reviews()
end
-
+
# Used for the permalink, e.g. http://localhost:9000/reviews/view/1
def view
@review = Review.find(params[:id], :include => ['project'])
render :text => "<b>Cannot delete the comment</b> : access denied."
return
end
-
+
if @review
@review.delete_comment(current_user, params[:comment_id].to_i)
end
return
end
- if @review.isResolved?
+ if @review.resolved?
@review.reopen(current_user)
else
# for the moment, if a review is not open, it can only be "RESOLVED"
# GET
def display_violation
violation = RuleFailure.find(params[:id])
- render :partial => "resource/violation", :locals => { :violation => violation }
+ render :partial => "resource/violation", :locals => {:violation => violation}
end
# GET
violation.review.reassign(current_user, assignee)
violation.save
- render :partial => "resource/violation", :locals => { :violation => violation }
+ render :partial => "resource/violation", :locals => {:violation => violation}
end
# GET
return
end
sanitize_violation(violation)
-
+
unless params[:comment].blank?
if violation.review.nil?
violation.build_review(:user_id => current_user.id)
violation=RuleFailure.find(params[:id])
end
- render :partial => "resource/violation", :locals => { :violation => violation }
+ render :partial => "resource/violation", :locals => {:violation => violation}
end
# GET
unless violation.review
assignee = findUserByLogin(params[:assignee_login]) unless params[:assignee_login].blank?
violation.create_review!(
- :assignee => assignee,
- :user => current_user)
+ :assignee => assignee,
+ :user => current_user)
end
unless params[:text].blank?
end
end
- render :partial => "resource/violation", :locals => { :violation => violation }
+ render :partial => "resource/violation", :locals => {:violation => violation}
end
# POST
if violation.review
violation.review.delete_comment(current_user, params[:comment_id].to_i)
end
- render :partial => "resource/violation", :locals => { :violation => violation }
+ render :partial => "resource/violation", :locals => {:violation => violation}
end
-
+
# POST
def violation_change_status
violation = RuleFailure.find(params[:id], :include => 'snapshot')
return
end
sanitize_violation(violation)
-
+
if violation.review
review = violation.review
- if review.isResolved?
+ if review.resolved?
review.reopen(current_user)
else
# for the moment, if a review is not open, it can only be "RESOLVED"
review.resolve(current_user)
end
- end
+ end
- render :partial => "resource/violation", :locals => { :violation => violation }
+ render :partial => "resource/violation", :locals => {:violation => violation}
end
# ACTIONS FROM THE REVIEW WIDGETS
#
#
-
+
# GET
def widget_reviews_list
@snapshot = Snapshot.find(params[:snapshot_id])
render :text => "<b>Cannot access the reviews of this project</b>: access denied."
return
end
-
+
@dashboard_configuration=Api::DashboardConfiguration.new(nil, :period_index => params[:period], :snapshot => @snapshot)
render :partial => 'project/widgets/reviews/reviews_list'
end
-
## -------------- PRIVATE -------------- ##
private
-
+
def findUserByLogin(login)
- User.find(:all, :conditions => [ "login = ?", login ]).first
+ User.find(:all, :conditions => ["login = ?", login]).first
end
-
+
def init_params
default_user = (current_user ? current_user.login : '')
@assignee_login = params[:assignee_login] || default_user
if @to
options['to']=@to
end
- unless @id == ''
+ unless @id == ''
if is_number? @id
options['id'] = @id
else
end
options['sort'] = @sort unless @sort.blank?
options['asc'] = @asc
-
+
found_reviews = Review.search(options)
@reviews = select_authorized(:user, found_reviews, :project)
if found_reviews.size != @reviews.size
@security_exclusions = true
end
-
+
# table pagination
@page_size = 20
@page_size = params[:page_size].to_i if is_number?(params[:page_size]) && params[:page_size].to_i > 5
def is_number?(s)
true if Float(s) rescue false
end
-
+
def has_rights_to_modify?(object)
current_user && has_role?(:user, object)
end
(status == STATUS_RESOLVED && resolution == RESOLUTION_FALSE_POSITIVE) || status == STATUS_OPEN || status == STATUS_REOPENED
end
- def isResolved?
+ def resolved?
status == STATUS_RESOLVED
end
- def isClosed?
+ def closed?
status == STATUS_CLOSED
end
- def isReopened?
+ def reopened?
status == STATUS_REOPENED
end
- def isOpen?
+ def open?
status == STATUS_OPEN
end
<div id="vId<%= violation.id -%>">
-<div class="violation">
- <div class="vtitle">
- <% if violation.review %>
- <div class="review_permalink"><span class="review_permalink"><%= link_to "Review #"+violation.review.id.to_s, :controller => "reviews", :action => "view", :id => violation.review.id -%></span></div>
- <% end %>
-
- <%= image_tag("priority/" + violation.failure_level.to_s + '.png') -%>
-
- <img src="<%= ApplicationController.root_context -%>/images/sep12.png">
-
- <span class="rulename" <%= 'style="text-decoration: line-through"' if violation.review && violation.review.isResolved? %> >
- <a onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => violation.rule.key, :layout => 'false' -%>"><%= h(violation.rule.name) -%></a>
- </span>
-
- <img src="<%= ApplicationController.root_context -%>/images/sep12.png">
-
- <% if violation.created_at %>
- <span class="violation_date"><%= distance_of_time_in_words_to_now(violation.created_at) -%></span>
-
- <% end %>
- <% if violation.switched_off? %>
- <img src="<%= ApplicationController.root_context -%>/images/sep12.png">
-
- <span class="falsePositive"><%= message('false_positive') -%></span>
+ <div class="violation">
+ <div class="vtitle">
+ <% if violation.review %>
+ <div class="review_permalink"><span class="review_permalink"><%= link_to "Review #"+violation.review.id.to_s, :controller => "reviews", :action => "view", :id => violation.review.id -%></span>
+ </div>
+ <% end %>
+
+ <%= image_tag("priority/" + violation.failure_level.to_s + '.png') -%>
- <% end %>
- <% if violation.review && violation.review.isReopened? %>
<img src="<%= ApplicationController.root_context -%>/images/sep12.png">
- <span class="review-reopened"><%= message('reopened') -%></span>
+ <span class="rulename" <%= 'style="text-decoration: line-through"' if violation.review && violation.review.resolved? %> >
+ <a onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => violation.rule.key, :layout => 'false' -%>"><%= h(violation.rule.name) -%></a>
+ </span>
- <% end %>
- <% if violation.review && violation.review.assignee_id %>
<img src="<%= ApplicationController.root_context -%>/images/sep12.png">
- <%= message('assigned_to') -%>: <%= h(violation.review.assignee.name) -%>
-
- <% end %>
-
- <% if current_user %>
+ <% if violation.created_at %>
+ <span class="violation_date"><%= distance_of_time_in_words_to_now(violation.created_at) -%></span>
+
+ <% end %>
+ <% if violation.switched_off? %>
+ <img src="<%= ApplicationController.root_context -%>/images/sep12.png">
+
+ <span class="falsePositive"><%= message('false_positive') -%></span>
+
+ <% end %>
+ <% if violation.review && violation.review.reopened? %>
+ <img src="<%= ApplicationController.root_context -%>/images/sep12.png">
+
+ <span class="review-reopened"><%= message('reopened') -%></span>
+
+ <% end %>
+ <% if violation.review && violation.review.assignee_id %>
+ <img src="<%= ApplicationController.root_context -%>/images/sep12.png">
+
+ <%= message('assigned_to') -%>: <%= h(violation.review.assignee.name) -%>
+
+ <% end %>
+
+ <% if current_user %>
<span class="actions" id="vActions<%= violation.id -%>">
<img src="<%= ApplicationController.root_context -%>/images/sep12.png">
- <%
- if violation.review
- unless violation.switched_off?
- %>
+ <%
+ if violation.review
+ unless violation.switched_off?
+ %>
- <%= link_to_remote (violation.review.isResolved? ? message('reopen') : message('resolve')),
- :url => { :controller => "reviews", :action => "violation_change_status", :id => violation.id},
- :update => "vId" + violation.id.to_s,
- :confirm => violation.review.isResolved? ? message('reviews.do_you_want_to_reopen') : message('reviews.do_you_want_to_resolve') -%>
-
- <% unless violation.review && violation.review.isResolved? %>
+ <%= link_to_remote (violation.review.resolved? ? message('reopen') : message('resolve')),
+ :url => {:controller => "reviews", :action => "violation_change_status", :id => violation.id},
+ :update => "vId" + violation.id.to_s,
+ :confirm => violation.review.resolved? ? message('reviews.do_you_want_to_reopen') : message('reviews.do_you_want_to_resolve') -%>
+
+ <% unless violation.review && violation.review.resolved? %>
- <%= link_to_remote (violation.review.assignee_id ? message('reassign') : message('assign')),
- :url => { :controller => "reviews", :action => "violation_assign_form", :violation_id => violation.id},
- :update => "vActions" + violation.id.to_s,
- :complete => "$('vActions" + violation.id.to_s + "').show();$('commentActions" + violation.id.to_s + "').hide();$('assignee_login').focus();" -%>
+ <%= link_to_remote (violation.review.assignee_id ? message('reassign') : message('assign')),
+ :url => {:controller => "reviews", :action => "violation_assign_form", :violation_id => violation.id},
+ :update => "vActions" + violation.id.to_s,
+ :complete => "$('vActions" + violation.id.to_s + "').show();$('commentActions" + violation.id.to_s + "').hide();$('assignee_login').focus();" -%>
<%
- end
- end
- else
- %>
+ end
+ end
+ else
+ %>
<%= link_to_remote message('review_verb'),
- :url => { :controller => "reviews", :action => "violation_comment_form", :id => violation.id },
- :update => "reviewForm" + violation.id.to_s,
- :complete => "$('reviewForm" + violation.id.to_s + "').show();$('commentText" + violation.id.to_s + "').focus();$('vActions#{violation.id}').hide();" -%>
+ :url => {:controller => "reviews", :action => "violation_comment_form", :id => violation.id},
+ :update => "reviewForm" + violation.id.to_s,
+ :complete => "$('reviewForm" + violation.id.to_s + "').show();$('commentText" + violation.id.to_s + "').focus();$('vActions#{violation.id}').hide();" -%>
<% end %>
-
-
- <% if (!violation.review) || (violation.review && violation.review.can_change_false_positive_flag?) %>
+
+
+ <% if (!violation.review) || (violation.review && violation.review.can_change_false_positive_flag?) %>
<%= link_to_remote (violation.switched_off? ? message('reviews.unflag_as_false_positive') : message('reviews.flag_as_false_positive')),
- :url => { :controller => "reviews", :action => "violation_false_positive_form", :id => violation.id, :false_positive => !violation.switched_off? },
- :update => "reviewForm" + violation.id.to_s,
- :complete => "$('reviewForm" + violation.id.to_s + "').show();$('commentText" + violation.id.to_s + "').focus();$('vActions" + violation.id.to_s + "').hide();$('commentActions" + violation.id.to_s + "').hide();" -%>
+ :url => {:controller => "reviews", :action => "violation_false_positive_form", :id => violation.id, :false_positive => !violation.switched_off?},
+ :update => "reviewForm" + violation.id.to_s,
+ :complete => "$('reviewForm" + violation.id.to_s + "').show();$('commentText" + violation.id.to_s + "').focus();$('vActions" + violation.id.to_s + "').hide();$('commentActions" + violation.id.to_s + "').hide();" -%>
<% end %>
</span>
- <% end %>
-
- </div>
+ <% end %>
- <div class="discussionComment first">
- <%= violation.html_message -%>
- </div>
+ </div>
+
+ <div class="discussionComment first">
+ <%= violation.html_message -%>
+ </div>
- <%
- if violation.review
- violation.review.comments.each_with_index do |review_comment, comment_index|
- is_last_comment=(comment_index==violation.review.comments.size-1)
- %>
- <div class="discussionComment">
- <h4><%= image_tag("reviews/comment.png") -%> <b><%= review_comment.user.name -%></b> (<%= distance_of_time_in_words_to_now(review_comment.created_at) -%>)
- <% if is_last_comment && current_user %>
+ <%
+ if violation.review
+ violation.review.comments.each_with_index do |review_comment, comment_index|
+ is_last_comment=(comment_index==violation.review.comments.size-1)
+ %>
+ <div class="discussionComment">
+ <h4><%= image_tag("reviews/comment.png") -%> <b><%= review_comment.user.name -%></b> (<%= distance_of_time_in_words_to_now(review_comment.created_at) -%>)
+ <% if is_last_comment && current_user %>
<span class="actions" id="commentActions<%= violation.id -%>">
<img src="<%= ApplicationController.root_context -%>/images/sep12.png">
<%= link_to_remote message('add_comment'),
- :url => { :controller => "reviews", :action => "violation_comment_form", :id => violation.id },
- :update => "reviewForm" + violation.id.to_s,
- :complete => "$('vActions#{violation.id}').hide();$('commentActions" + violation.id.to_s + "').hide();$('reviewForm" + violation.id.to_s + "').show();$('commentText" + violation.id.to_s + "').focus()" -%>
- <%
- if current_user.id == review_comment.user_id
+ :url => {:controller => "reviews", :action => "violation_comment_form", :id => violation.id},
+ :update => "reviewForm" + violation.id.to_s,
+ :complete => "$('vActions#{violation.id}').hide();$('commentActions" + violation.id.to_s + "').hide();$('reviewForm" + violation.id.to_s + "').show();$('commentText" + violation.id.to_s + "').focus()" -%>
+ <%
+ if current_user.id == review_comment.user_id
%>
- <%= link_to_remote message('edit'),
- :url => { :controller => "reviews", :action => "violation_comment_form", :comment_id => review_comment.id, :id => violation.id },
- :update => "lastComment" + violation.id.to_s,
- :complete => "$('vActions#{violation.id}').hide();$('commentActions#{violation.id}').hide();$('commentText#{violation.id}').focus();" -%>
+ <%= link_to_remote message('edit'),
+ :url => {:controller => "reviews", :action => "violation_comment_form", :comment_id => review_comment.id, :id => violation.id},
+ :update => "lastComment" + violation.id.to_s,
+ :complete => "$('vActions#{violation.id}').hide();$('commentActions#{violation.id}').hide();$('commentText#{violation.id}').focus();" -%>
<% unless comment_index == 0 %>
- <%= link_to_remote message('delete'),
- :url => { :controller => "reviews", :action => "violation_delete_comment", :comment_id => review_comment.id, :id => violation.id },
- :update => "vId" + violation.id.to_s,
- :confirm => message('reviews.do_you_want_to_delete_comment') -%>
+ <%= link_to_remote message('delete'),
+ :url => {:controller => "reviews", :action => "violation_delete_comment", :comment_id => review_comment.id, :id => violation.id},
+ :update => "vId" + violation.id.to_s,
+ :confirm => message('reviews.do_you_want_to_delete_comment') -%>
<% end %>
<%
- end
+ end
%>
</span>
- <% end %>
- </h4>
- <% if is_last_comment %>
- <div id="lastComment<%= violation.id -%>">
- <%= review_comment.html_text -%>
+ <% end %>
+ </h4>
+ <% if is_last_comment %>
+ <div id="lastComment<%= violation.id -%>">
+ <%= review_comment.html_text -%>
+ </div>
+ <% else %>
+ <%= review_comment.html_text -%>
+ <% end %>
</div>
- <% else %>
- <%= review_comment.html_text -%>
- <% end %>
- </div>
- <%
- end
- end
- %>
+ <%
+ end
+ end
+ %>
- <div class="discussionComment" id="reviewForm<%= violation.id -%>" style="display:none"></div>
-</div>
+ <div class="discussionComment" id="reviewForm<%= violation.id -%>" style="display:none"></div>
+ </div>
</div>
\ No newline at end of file
<span class="falsePositive"><%= message('false_positive') -%></span>
<% end %>
-
- <%
- if current_user && !review.isClosed? && review.rule_failure
- violation_switched_off = review.rule_failure.switched_off?
+
+ <%
+ if current_user && !review.closed? && review.rule_failure
+ violation_switched_off = review.rule_failure.switched_off?
%>
<span class="actions" id="rActions">
- <%= image_tag("sep12.png") -%>
+ <%= image_tag("sep12.png") -%>
+
+ <%
+ if !violation_switched_off
+ %>
+ <%= link_to_remote (review.resolved? ? message('reopen') : message('resolve')),
+ :url => {:controller => "reviews", :action => "change_status", :id => review.id},
+ :update => "review",
+ :confirm => review.resolved? ? message('reviews.do_you_want_to_reopen') : message('reviews.do_you_want_to_resolve') -%>
- <%
- if !violation_switched_off
- %>
- <%= link_to_remote (review.isResolved? ? message('reopen') : message('resolve')),
- :url => { :controller => "reviews", :action => "change_status", :id => review.id},
- :update => "review",
- :confirm => review.isResolved? ? message('reviews.do_you_want_to_reopen') : message('reviews.do_you_want_to_resolve') -%>
+ <% unless review.resolved? %>
+ <%= link_to_remote (review.assignee_id ? message('reassign') : message('assign')),
+ :url => {:controller => "reviews", :action => "assign_form", :review_id => review.id},
+ :update => "assignForm",
+ :complete => "$('rActions').hide(); $('editActions').hide(); $('assignee_login').focus();" -%>
+
- <% unless review.isResolved? %>
- <%= link_to_remote (review.assignee_id ? message('reassign') : message('assign')),
- :url => { :controller => "reviews", :action => "assign_form", :review_id => review.id},
- :update => "assignForm",
- :complete => "$('rActions').hide(); $('editActions').hide(); $('assignee_login').focus();" -%>
-
-
<% end %>
<% end %>
- <% if review.can_change_false_positive_flag? %>
+ <% if review.can_change_false_positive_flag? %>
<%= link_to_remote (violation_switched_off ? message('reviews.unflag_as_false_positive') : message('reviews.flag_as_false_positive')),
- :url => { :controller => "reviews", :action => "false_positive_form", :id => review.id, :false_positive => !violation_switched_off },
- :update => "reviewForm",
- :complete => "$('reviewForm').show(); $('rActions').hide(); $('editActions').hide(); $('commentText').focus();" -%>
+ :url => {:controller => "reviews", :action => "false_positive_form", :id => review.id, :false_positive => !violation_switched_off},
+ :update => "reviewForm",
+ :complete => "$('reviewForm').show(); $('rActions').hide(); $('editActions').hide(); $('commentText').focus();" -%>
<% end %>
</span>
<% end %>
-
+
</div>
<table class="reportDetails">
- <tr>
- <td class="key">
- <%= message('status') -%>:
- </td>
- <td class="val">
- <%= image_tag "status/#{review.status}.png" -%> <%= message(review.status.downcase).capitalize -%>
- </td>
- <td class="key">
- <%= message('severity') -%>:
- </td>
- <td class="val">
- <%= image_tag "priority/#{review.severity}.png" -%> <%= message(review.severity.downcase).capitalize -%>
- </td>
- </tr>
- <tr>
- <td class="key">
- <%= message('assignee') -%>:
- </td>
- <td class="val">
+ <tr>
+ <td class="key">
+ <%= message('status') -%>:
+ </td>
+ <td class="val">
+ <%= image_tag "status/#{review.status}.png" -%> <%= message(review.status.downcase).capitalize -%>
+ </td>
+ <td class="key">
+ <%= message('severity') -%>:
+ </td>
+ <td class="val">
+ <%= image_tag "priority/#{review.severity}.png" -%> <%= message(review.severity.downcase).capitalize -%>
+ </td>
+ </tr>
+ <tr>
+ <td class="key">
+ <%= message('assignee') -%>:
+ </td>
+ <td class="val">
<span id="assignForm">
- <%= review.assignee ? h(review.assignee.name) : '-'-%>
+ <%= review.assignee ? h(review.assignee.name) : '-' -%>
</span>
- </td>
- <td class="key">
- <%= message('author') -%>:
- </td>
- <td class="val">
- <%= h(review.user.name) -%>
- </td>
- </tr>
- <tr>
- <td class="key">
- <%= message('created') -%>:
- </td>
- <td class="val">
- <%= l(review.created_at) -%>
- </td>
- <td class="key">
- <%= message('updated') -%>:
- </td>
- <td class="val">
- <%= l(review.updated_at) -%>
- </td>
- </tr>
- <% if review.rule %>
- <tr>
- <td class="key">
- <%= message('rule') -%>:
- </td>
- <td class="val" colspan="3">
- <a onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => review.rule.key, :layout => 'false' -%>"><%= h(review.rule.name) -%></a>
- </td>
- </tr>
- <% end %>
- <tr>
- <td class="key">
- <%= message('file') -%>:
- </td>
- <td class="val" colspan="3">
- <%= qualifier_icon(review.resource) -%>
- <% if !review.on_project? %> <%= review.project.long_name -%> <%= image_tag 'sep12.png' -%> <% end %>
- <%= link_to_resource(review.resource, review.resource.long_name, { :tab => :violations, :rule => review.false_positive ? "f-positive" : "" } ) %>
- </td>
- </tr>
+ </td>
+ <td class="key">
+ <%= message('author') -%>:
+ </td>
+ <td class="val">
+ <%= h(review.user.name) -%>
+ </td>
+ </tr>
+ <tr>
+ <td class="key">
+ <%= message('created') -%>:
+ </td>
+ <td class="val">
+ <%= l(review.created_at) -%>
+ </td>
+ <td class="key">
+ <%= message('updated') -%>:
+ </td>
+ <td class="val">
+ <%= l(review.updated_at) -%>
+ </td>
+ </tr>
+ <% if review.rule %>
+ <tr>
+ <td class="key">
+ <%= message('rule') -%>:
+ </td>
+ <td class="val" colspan="3">
+ <a onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => review.rule.key, :layout => 'false' -%>"><%= h(review.rule.name) -%></a>
+ </td>
+ </tr>
+ <% end %>
+ <tr>
+ <td class="key">
+ <%= message('file') -%>:
+ </td>
+ <td class="val" colspan="3">
+ <%= qualifier_icon(review.resource) -%>
+ <% if !review.on_project? %> <%= review.project.long_name -%> <%= image_tag 'sep12.png' -%>
+ <% end %>
+ <%= link_to_resource(review.resource, review.resource.long_name, {:tab => :violations, :rule => review.false_positive ? "f-positive" : ""}) %>
+ </td>
+ </tr>
</table>
<% if review.rule_failure && review.resource_line && review.rule_failure.snapshot && has_role?(:codeviewer, review.project) %>
<% end %>
<div class="discussion">
- <% if review.rule_failure %>
- <div class="discussionComment first">
- <%= h(review.rule_failure.message) -%>
- </div>
- <% end %>
- <%
- review.comments.each_with_index do |comment, comment_index|
- is_last_comment=(comment_index==review.comments.size-1)
- %>
- <div class="discussionComment">
- <h4>
- <%= image_tag("reviews/comment.png") -%> <b><%= comment.user.name -%></b> (<%= distance_of_time_in_words_to_now(comment.created_at) -%>)
- <% if is_last_comment && current_user && !review.isClosed? %>
+ <% if review.rule_failure %>
+ <div class="discussionComment first">
+ <%= h(review.rule_failure.message) -%>
+ </div>
+ <% end %>
+ <%
+ review.comments.each_with_index do |comment, comment_index|
+ is_last_comment=(comment_index==review.comments.size-1)
+ %>
+ <div class="discussionComment">
+ <h4>
+ <%= image_tag("reviews/comment.png") -%> <b><%= comment.user.name -%></b> (<%= distance_of_time_in_words_to_now(comment.created_at) -%>)
+ <% if is_last_comment && current_user && !review.closed? %>
<span class="actions" id="editActions">
<%= image_tag("sep12.png") -%>
<%= link_to_remote message('add_comment'),
- :url => { :controller => "reviews", :action => "comment_form", :id => review.id },
- :update => "reviewForm",
- :complete => "$('rActions').hide();$('editActions').hide();$('reviewForm').show();$('commentText').focus();" -%>
+ :url => {:controller => "reviews", :action => "comment_form", :id => review.id},
+ :update => "reviewForm",
+ :complete => "$('rActions').hide();$('editActions').hide();$('reviewForm').show();$('commentText').focus();" -%>
<%
- if current_user.id == comment.user_id
+ if current_user.id == comment.user_id
%>
- <%= link_to_remote message('edit'),
- :url => { :controller => "reviews", :action => "comment_form", :comment_id => comment.id, :id => review.id },
- :update => "lastComment",
- :complete => "$('rActions').hide();$('editActions').hide();$('commentText').focus();" -%>
- <% unless comment_index == 0 %>
+ <%= link_to_remote message('edit'),
+ :url => {:controller => "reviews", :action => "comment_form", :comment_id => comment.id, :id => review.id},
+ :update => "lastComment",
+ :complete => "$('rActions').hide();$('editActions').hide();$('commentText').focus();" -%>
+ <% unless comment_index == 0 %>
- <%= link_to_remote message('delete'),
- :url => { :controller => "reviews", :action => "delete_comment", :comment_id => comment.id, :id => review.id },
- :update => "review",
- :confirm => message('reviews.do_you_want_to_delete_comment') -%>
+ <%= link_to_remote message('delete'),
+ :url => {:controller => "reviews", :action => "delete_comment", :comment_id => comment.id, :id => review.id},
+ :update => "review",
+ :confirm => message('reviews.do_you_want_to_delete_comment') -%>
<% end %>
- <%
- end
+ <%
+ end
%>
</span>
- <% end %>
- </h4>
- <% if is_last_comment %>
- <div id="lastComment">
- <%= comment.html_text -%>
- </div>
- <% else %>
- <%= comment.html_text -%>
- <% end %>
- </div>
- <% end %>
+ <% end %>
+ </h4>
+ <% if is_last_comment %>
+ <div id="lastComment">
+ <%= comment.html_text -%>
+ </div>
+ <% else %>
+ <%= comment.html_text -%>
+ <% end %>
+ </div>
+ <% end %>
</div>
-
+
<div class="discussionComment" id="reviewForm" style="display:none"></div>
-
+
</div>
\ No newline at end of file