return
end
+ false_positive=(params[:false_positive]=='true')
RuleFailure.find( :all, :conditions => [ "permanent_id = ?", @review.rule_failure_permanent_id ] ).each do |violation|
- violation.switched_off=true
+ violation.switched_off=false_positive
violation.save!
end
- @review.review_type = Review::TYPE_FALSE_POSITIVE
- @review.status = Review::STATUS_CLOSED
+ @review.review_type = (false_positive ? Review::TYPE_FALSE_POSITIVE : Review::TYPE_VIOLATION)
@review.assignee = nil
@review.save!
unless params[:comment].blank?
violation.build_review(:user_id => current_user.id)
end
violation.review.review_type=(false_positive ? Review::TYPE_FALSE_POSITIVE : Review::TYPE_VIOLATION)
- violation.review.status=(false_positive ? Review::STATUS_CLOSED : Review::STATUS_OPEN)
violation.review.assignee=nil
violation.review.save!
violation.review.comments.create(:review_text => params[:comment], :user_id => current_user.id)
end
end
+
+
+ #
+ #
+ # REVIEW CORE METHODS
+ #
+ #
+
def create_comment(options={})
comments.create!(options)
touch
end
end
+
+
+ #
+ #
+ # SEARCH METHODS
+ #
+ #
+
def self.search(options={})
conditions=[]
values={}
Review.find(:all, :include => [ 'review_comments', 'project', 'assignee', 'resource', 'user' ], :conditions => [conditions.join(' AND '), values], :order => sort, :limit => 200)
end
+
+
+ #
+ #
+ # XML AND JSON UTILITY METHODS
+ #
+ #
+
def self.reviews_to_xml(reviews, convert_markdown=false)
xml = Builder::XmlMarkup.new(:indent => 0)
xml.instruct!
-
+ #
+ #
+ # PRIVATE METHODS
+ #
+ #
private
-
-
def assign_project
if self.project.nil? && self.resource
self.project=self.resource.root_project
<form method="POST" action="violation_flag_as_false_positive">
<input type="hidden" name="id" value="<%= params[:id] -%>"/>
+ <% if params[:false_positive]=='true' -%>
+ <input type="hidden" name="false_positive" value="true"/>
+ <% end %>
<h3>Why is it a false-positive ?</h3>
<textarea id="commentText" rows="8" name="comment" style="width: 100%" onkeyup="if (this.value=='') $('submit_btn').disabled='true'; else $('submit_btn').disabled='';"></textarea>
<%= submit_to_remote "submit_btn", "Flag as false-positive", :url => { :action => 'flag_as_false_positive' }, :html => { :id => "submit_btn", :disabled => "true" }, :update => 'review' -%>
<div class="reportTitle">
<h2>Review #<%= h(review.id.to_s) -%> - <%= h(review.title) -%></h2>
- <% if current_user && review.status != "CLOSED" %>
+ <%
+ if current_user && review.status != "CLOSED" && review.rule_failure
+ violation_switched_off = review.rule_failure.switched_off?
+ %>
<span class="actions" id="rActions">
<%= image_tag("sep12.png") -%>
+ <%
+ if !violation_switched_off
+ %>
<%= link_to_remote (review.assignee_id ? "Reassign" : "Assign"),
:url => { :controller => "reviews", :action => "assign_form", :review_id => review.id},
:update => "assignForm",
:complete => "$('rActions').hide(); $('editActions').hide(); $('assignee_id').focus();" -%>
- <%= link_to_remote ("Flag as false-positive"),
- :url => { :controller => "reviews", :action => "false_positive_form", :id => review.id },
+ <% end %>
+ <%= link_to_remote (violation_switched_off ? "Unflag as false-positive" : "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();" -%>
</span>