end
end
- RuleFailure.find(:all, :include => 'rule', :conditions => [conditions] + values, :order => 'failure_level DESC').each do |violation|
+ RuleFailure.find(:all, :include => ['rule', 'reviews', { 'reviews' => 'review_data' } ], :conditions => [conditions] + values, :order => 'failure_level DESC').each do |violation|
# sorted by severity => from blocker to info
if violation.line && violation.line>0 && @lines
@lines[violation.line-1].add_violation(violation)
--- /dev/null
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# Sonar is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+
+class ReviewsController < ApplicationController
+
+ SECTION=Navigation::SECTION_CONFIGURATION
+
+ def index
+ end
+
+ def form
+ @review = Review.new
+ @review.rule_failure_id = params[:violation_id]
+ @review.user = current_user
+ @review_data = ReviewData.new
+ @review_data.user = current_user
+ @review_data.review = @review
+ @review_data.review_text = "Enter your review here"
+ render "_form", :layout => false
+ end
+
+ def create
+ review = Review.new(params[:review])
+ review.user = current_user
+ review.save
+ review_data = ReviewData.new(params[:review_data])
+ review_data.user = current_user
+ review_data.review_id = review.id
+ review_data.save
+ #render "_view", :layout => false
+ end
+
+ def cancel_create
+ render :nothing => true
+ end
+
+end
belongs_to :user
belongs_to :rule_failure
belongs_to :resource, :class_name => 'Project', :foreign_key => 'resource_id'
- has_many :review_data, :order => created_at, :dependent => :destroy
+ has_many :review_data, :order => "created_at", :dependent => :destroy
validates_presence_of :user
validates_presence_of :review_type
validates_presence_of :status
- validate :review_must_have_at_least_one_comment
-
- def review_must_have_at_least_one_comment
- errors.add("A review must have at least one comment.") if
- review_data.length < 1
- end
end
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
#
class ReviewData < ActiveRecord::Base
+ set_table_name :review_data
+
belongs_to :user
belongs_to :review
validates_presence_of :user
belongs_to :rule
belongs_to :snapshot
+ has_many :reviews, :order => "created_at"
def to_hash_json
json = {}
<div class="violation">
-<img src="<%= ApplicationController.root_context -%>/images/priority/<%=violation.failure_level-%>.png"/>
-
-<span class="rulename"><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>
- »
-<%= violation_html_message(violation) -%>
-<%
- if violation.created_at
- duration=Date.today - violation.created_at.to_date
-
-%>
- <span class="violation_date"><%= duration==0 ? 'today' : "#{duration} days ago" -%></span>
-<% end %>
- </div>
\ No newline at end of file
+ <table>
+ <tr>
+
+ <td width="30px" valign="top">
+ <% if current_user %>
+ <%= link_to_remote(image_tag("add.png"),
+ :update => "review" + violation.id.to_s ,
+ :url => { :controller => "reviews", :action => "form", :violation_id => violation.id }) -%>
+ <% end %>
+ </td>
+
+ <td>
+ <img src="<%= ApplicationController.root_context -%>/images/priority/<%=violation.failure_level-%>.png"/>
+
+ <span class="rulename"><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>
+ »
+ <%= h(violation.message) -%>
+ <%
+ if violation.created_at
+ duration=Date.today - violation.created_at.to_date
+ %>
+ <span class="violation_date"><%= duration==0 ? 'today' : "#{duration} days ago" -%></span>
+ <% end %>
+
+ <div id="review<%= violation.id -%>" style="padding:5px; background:white">
+ <% unless violation.reviews.blank?
+ violation.reviews.each do |review|
+ %>
+ <%= render :partial => "reviews/view", :locals => { :review => review } %>
+ <%
+ end
+ end
+ %>
+ </div>
+ </td>
+
+ </tr>
+ </table>
+</div>
--- /dev/null
+<% form_for :review, @review, :url => { :action => 'create', :id => @review.id } do |f| %>
+ <%= f.hidden_field :rule_failure_id %>
+ Review by: <%= @review.user.login -%>
+ <br/>
+ Review type: <%= f.text_field :review_type %>
+ <br/>
+ Status: <%= f.text_field :status %>
+ <br/>
+ Severity: <%= f.text_field :severity %>
+ <br/>
+ External Link: <%= f.text_field :external_link %>
+ <br/>
+ Comment:
+ <br/>
+ <%= text_area :review_data, :review_text, :rows => 10 %>
+ <br/>
+ <%= submit_to_remote 'create_btn', 'Create review',
+ :url => { :action => 'create', :id => @review.id },
+ :update => { :success => "review" + @review.rule_failure_id.to_s, :failure => "fail" } %>
+ <%= submit_to_remote 'cancel_btn', 'Cancel',
+ :url => { :action => 'cancel_create' },
+ :update => { :success => "review" + @review.rule_failure_id.to_s } %>
+<% end %>
\ No newline at end of file
--- /dev/null
+<div>
+ Review Id: <%= review.id -%>
+ <br/>
+ Review Id: <%= review.user.name -%>
+ <br/>
+ Review type: <%= review.review_type -%>
+ <br/>
+ Status: <%= review.status -%>
+ <br/>
+ Severity: <%= review.severity -%>
+ <br/>
+ External Link: <%= review.external_link -%>
+ <br/>
+
+ <% unless review.review_data.blank?
+ review.review_data.each do |review_data|
+ %>
+ Comment: <%= review_data.review_text -%>
+ <br/>
+ <%
+ end
+ end
+ %>
+</div>
\ No newline at end of file
--- /dev/null
+Created!
\ No newline at end of file
--- /dev/null
+Hello !
\ No newline at end of file
t.column 'user_id', :integer, :null => true
t.column 'review_type', :string, :null => true, :limit => 10
t.column 'status', :string, :null => true, :limit => 10
- t.column 'severity', :integer, :null => true
+ t.column 'severity', :string, :null => true, :limit => 10
t.column 'external_link', :string, :null => true, :limit => 200
t.column 'rule_failure_id', :integer, :null => true
t.column 'resource_id', :integer, :null => true