haru/redmine_code_review

View on GitHub
app/views/code_review/_change_revision_view.html.erb

Summary

Maintainability
Test Coverage
<%
# Code Review plugin for Redmine
# Copyright (C) 2010-2011  Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-%>
<%
repository_id = @repository.identifier_param if @repository.respond_to?("identifier_param")
if @changeset
  urlprefix = url_for(:controller => 'repositories', :action => 'revisions', :id => project, :repository_id => repository_id) +
    '/' + @changeset.identifier + '/entry'
%>
<%- if User.current.allowed_to?(:assign_code_review, @project) -%>
  <div id="code_review_assignments">
    <%=h l(:review_assignments)%>
    <% @changeset.code_review_assignments.each do |assignment|
      issue = assignment.issue %>
      <%= link_to("##{issue.id} ", {:controller => 'issues', :action => 'show', :id => issue.id},
        :class => issue.css_classes, :title => "#{issue}(#{issue.status})") %>
    <% end if @changeset.code_review_assignments %>

    <%= link_to(l(:button_add), {:controller => 'code_review',
        :action => 'assign', :id=>project, 
        :rev => @changeset.revision, 
        :changeset_id => @changeset.id, :repository_id => repository_id}, :class => 'icon icon-add') %>
  </div>
<%- end -%>

  <script type="text/javascript">
    $('#changes-legend').after($('#code_review_assignments'));
    urlprefix = '<%=urlprefix%>';
  <% @changeset.changes.each{|change| %>
    var reviewlist = [];
    <%
    cnt = 0
    change.code_reviews.each {|review|
      issue = review.issue
      url = link_to('#' + "#{issue.id} #{review.subject}(#{issue.status})",
        :controller => 'code_review', :action => 'show', :id => project, :review_id => review.id, :repository_id => repository_id)
    %>
      var review = new CodeReview(<%=review.id%>);
      review.url = '<%=url%>';
      <% if review.is_closed? %>
        review.is_closed = true;
      <% end %>
      reviewlist[<%=cnt%>] = review;
      <%
      cnt += 1

    }
    relative_path = change.path || ""
    if relative_path[0] != ?/
      relative_path = '/' + relative_path
    end
    escaped_relative_path = relative_path.gsub("'"){"\\'"}
  %>
    code_reviews_map['<%=escaped_relative_path-%>'] = reviewlist;
  <%
  }
%>
  UpdateRevisionView();
  </script>
<% end %>