Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
commit
b04992b226
Binary file not shown.
Binary file not shown.
@ -0,0 +1,136 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2014 Jean-Philippe Lang
|
||||
#
|
||||
# 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.
|
||||
|
||||
require 'cgi'
|
||||
|
||||
module Redmine
|
||||
module WikiFormatting
|
||||
module Markdown
|
||||
class HTML < Redcarpet::Render::HTML
|
||||
include ActionView::Helpers::TagHelper
|
||||
|
||||
def link(link, title, content)
|
||||
css = nil
|
||||
unless link && link.starts_with?('/')
|
||||
css = 'external'
|
||||
end
|
||||
content_tag('a', content.html_safe, :href => link, :title => title, :class => css)
|
||||
end
|
||||
|
||||
def block_code(code, language)
|
||||
if language.present?
|
||||
"<pre><code class=\"#{CGI.escapeHTML language} syntaxhl\">" +
|
||||
Redmine::SyntaxHighlighting.highlight_by_language(code, language) +
|
||||
"</code></pre>"
|
||||
else
|
||||
"<pre>" + CGI.escapeHTML(code) + "</pre>"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Formatter
|
||||
def initialize(text)
|
||||
@text = text
|
||||
end
|
||||
|
||||
def to_html(*args)
|
||||
html = formatter.render(@text)
|
||||
# restore wiki links eg. [[Foo]]
|
||||
html.gsub!(%r{\[<a href="(.*?)">(.*?)</a>\]}) do
|
||||
"[[#{$2}]]"
|
||||
end
|
||||
# restore Redmine links with double-quotes, eg. version:"1.0"
|
||||
html.gsub!(/(\w):"(.+?)"/) do
|
||||
"#{$1}:\"#{$2}\""
|
||||
end
|
||||
html
|
||||
end
|
||||
|
||||
def get_section(index)
|
||||
section = extract_sections(index)[1]
|
||||
hash = Digest::MD5.hexdigest(section)
|
||||
return section, hash
|
||||
end
|
||||
|
||||
def update_section(index, update, hash=nil)
|
||||
t = extract_sections(index)
|
||||
if hash.present? && hash != Digest::MD5.hexdigest(t[1])
|
||||
raise Redmine::WikiFormatting::StaleSectionError
|
||||
end
|
||||
t[1] = update unless t[1].blank?
|
||||
t.reject(&:blank?).join "\n\n"
|
||||
end
|
||||
|
||||
def extract_sections(index)
|
||||
sections = ['', '', '']
|
||||
offset = 0
|
||||
i = 0
|
||||
l = 1
|
||||
inside_pre = false
|
||||
@text.split(/(^(?:.+\r?\n\r?(?:\=+|\-+)|#+.+|~~~.*)\s*$)/).each do |part|
|
||||
level = nil
|
||||
if part =~ /\A~{3,}(\S+)?\s*$/
|
||||
if $1
|
||||
if !inside_pre
|
||||
inside_pre = true
|
||||
end
|
||||
else
|
||||
inside_pre = !inside_pre
|
||||
end
|
||||
elsif inside_pre
|
||||
# nop
|
||||
elsif part =~ /\A(#+).+/
|
||||
level = $1.size
|
||||
elsif part =~ /\A.+\r?\n\r?(\=+|\-+)\s*$/
|
||||
level = $1.include?('=') ? 1 : 2
|
||||
end
|
||||
if level
|
||||
i += 1
|
||||
if offset == 0 && i == index
|
||||
# entering the requested section
|
||||
offset = 1
|
||||
l = level
|
||||
elsif offset == 1 && i > index && level <= l
|
||||
# leaving the requested section
|
||||
offset = 2
|
||||
end
|
||||
end
|
||||
sections[offset] << part
|
||||
end
|
||||
sections.map(&:strip)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def formatter
|
||||
@@formatter ||= Redcarpet::Markdown.new(
|
||||
Redmine::WikiFormatting::Markdown::HTML.new(
|
||||
:filter_html => true,
|
||||
:hard_wrap => true
|
||||
),
|
||||
:autolink => true,
|
||||
:fenced_code_blocks => true,
|
||||
:space_after_headers => true,
|
||||
:tables => true,
|
||||
:strikethrough => true,
|
||||
:superscript => true
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,45 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2014 Jean-Philippe Lang
|
||||
#
|
||||
# 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.
|
||||
|
||||
module Redmine
|
||||
module WikiFormatting
|
||||
module Markdown
|
||||
module Helper
|
||||
def wikitoolbar_for(field_id)
|
||||
heads_for_wiki_formatter
|
||||
javascript_tag("var wikiToolbar = new jsToolBar(document.getElementById('#{field_id}')); wikiToolbar.draw();")
|
||||
end
|
||||
|
||||
def initial_page_content(page)
|
||||
"# #{@page.pretty_title}"
|
||||
end
|
||||
|
||||
def heads_for_wiki_formatter
|
||||
unless @heads_for_wiki_formatter_included
|
||||
content_for :header_tags do
|
||||
javascript_include_tag('jstoolbar/jstoolbar') +
|
||||
javascript_include_tag('jstoolbar/markdown') +
|
||||
javascript_include_tag("jstoolbar/lang/jstoolbar-#{current_language.to_s.downcase}") +
|
||||
stylesheet_link_tag('jstoolbar')
|
||||
end
|
||||
@heads_for_wiki_formatter_included = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,35 @@
|
||||
= Redmine Code Review Plugin
|
||||
|
||||
This is a plugin for Redmine which lets you annotate source code within the repository browser.
|
||||
|
||||
http://www.r-labs.org/wiki/r-labs/Code_Review
|
||||
|
||||
=== Plugin installation
|
||||
|
||||
1. Copy the plugin directory into the plugins directory
|
||||
|
||||
2. Migrate plugin:
|
||||
rake redmine:plugins:migrate RAILS_ENV=production
|
||||
|
||||
3. Start Redmine
|
||||
|
||||
4. Add code review module into your project.
|
||||
|
||||
5. Go to code review setting tab in the project setting page and select tracker.
|
||||
|
||||
=== Language contributors
|
||||
|
||||
* de.yml - Michael Diederich, Sebastian Bernhard
|
||||
* fr.yml - Thomas M
|
||||
* hu.yml - Péter Major
|
||||
* ko.yml - Ki-yong Kim, Ki Won Kim
|
||||
* nl.yml - Stefan Verstege
|
||||
* pt-br.yml - Alessandro Hecht
|
||||
* zh.yml - Marshall Wu
|
||||
* zh-tw.yml - Andrew Liu
|
||||
* ru.yml - Mykhaylo Sorochan
|
||||
* sk.yml - Milan Freml
|
||||
* es.yml - Ignacio Carrera
|
||||
* pl.yml - Rafal Grzymkowski
|
||||
* sv.yml - André Jonsson
|
||||
* bg.yml - Ivan Cenov, jwalkerbg
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,119 @@
|
||||
# Code Review plugin for Redmine
|
||||
# Copyright (C) 2010 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.
|
||||
|
||||
class CodeReviewSettingsController < ApplicationController
|
||||
unloadable
|
||||
layout 'base'
|
||||
menu_item :code_review
|
||||
include CodeReviewAutoAssignSettings
|
||||
|
||||
before_filter :find_project, :authorize, :find_user
|
||||
|
||||
def update
|
||||
begin
|
||||
@setting = CodeReviewProjectSetting.find_or_create(@project)
|
||||
|
||||
@setting.safe_attributes = params[:setting]
|
||||
@setting.updated_by = @user.id
|
||||
params[:auto_assign][:filters] = params[:auto_assign][:filters].values unless params[:auto_assign][:filters].blank?
|
||||
@setting.auto_assign_settings = params[:auto_assign].to_yaml
|
||||
|
||||
@setting.save!
|
||||
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
rescue ActiveRecord::StaleObjectError
|
||||
# Optimistic locking exception
|
||||
flash[:error] = l(:notice_locking_conflict)
|
||||
end
|
||||
redirect_to :controller => 'projects', :action => "settings", :id => @project, :tab => 'code_review'
|
||||
|
||||
end
|
||||
|
||||
def add_filter
|
||||
setting = CodeReviewProjectSetting.find_or_create(@project)
|
||||
@auto_assign = setting.auto_assign_settings
|
||||
filters = params[:auto_assign][:filters].values unless params[:auto_assign][:filters].blank?
|
||||
filters = [] unless filters
|
||||
filters << params[:auto_assign_add_filter]
|
||||
|
||||
@auto_assign.filters = filters.collect{|f|
|
||||
filter = AssignmentFilter.new
|
||||
filter.attributes = f
|
||||
filter
|
||||
}
|
||||
@auto_assign.filter_enabled = true
|
||||
render :partial => "code_review_settings/filters"
|
||||
end
|
||||
|
||||
def edit_filter
|
||||
setting = CodeReviewProjectSetting.find_or_create(@project)
|
||||
@auto_assign = setting.auto_assign_settings
|
||||
num = params[:num].to_i
|
||||
filters = params[:auto_assign][:filters].values unless params[:auto_assign][:filters].blank?
|
||||
filters = [] unless filters
|
||||
i = 0
|
||||
@auto_assign.filters = filters.collect{|f|
|
||||
filter = AssignmentFilter.new
|
||||
if i == num
|
||||
filter.attributes = params[:auto_assign_edit_filter][num.to_s]
|
||||
else
|
||||
filter.attributes = f
|
||||
end
|
||||
i = i + 1
|
||||
filter
|
||||
}
|
||||
render :partial => "code_review_settings/filters"
|
||||
end
|
||||
|
||||
def sort
|
||||
setting = CodeReviewProjectSetting.find_or_create(@project)
|
||||
@auto_assign = setting.auto_assign_settings
|
||||
filters = params[:auto_assign][:filters].values unless params[:auto_assign][:filters].blank?
|
||||
filters = [] unless filters
|
||||
num = params[:auto_assign_filter][:num].to_i
|
||||
move_to = params[:auto_assign_filter][:move_to]
|
||||
|
||||
if move_to == 'highest'
|
||||
filters[num][:order] = 0
|
||||
elsif move_to == 'higher'
|
||||
filters[num][:order] = filters[num][:order].to_i - 15
|
||||
elsif move_to == 'lower'
|
||||
filters[num][:order] = filters[num][:order].to_i + 15
|
||||
elsif move_to == 'lowest'
|
||||
filters[num][:order] = 999999999
|
||||
end
|
||||
|
||||
@auto_assign.filters = filters.collect{|f|
|
||||
filter = AssignmentFilter.new
|
||||
filter.attributes = f
|
||||
filter
|
||||
}
|
||||
|
||||
|
||||
render :partial => "code_review_settings/filters"
|
||||
end
|
||||
private
|
||||
def find_project
|
||||
# @project variable must be set before calling the authorize filter
|
||||
@project = Project.find(params[:id])
|
||||
end
|
||||
|
||||
def find_user
|
||||
@user = User.current
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,37 @@
|
||||
# Code Review plugin for Redmine
|
||||
# Copyright (C) 2009-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.
|
||||
module CodeReviewHelper
|
||||
unloadable
|
||||
def show_assignments(assignments, project, options = {})
|
||||
html = "#{l(:review_assignments)}:"
|
||||
assignments.each do |assignment|
|
||||
issue = assignment.issue
|
||||
html << link_to("##{issue.id} ", {:controller => 'issues', :action => 'show', :id => issue.id},
|
||||
:class => issue.css_classes, :title => "#{issue}(#{issue.status})")
|
||||
end if assignments
|
||||
|
||||
link = link_to(l(:button_add), {:controller => 'code_review',
|
||||
:action => 'assign', :id=>project, :action_type => options[:action_type],
|
||||
:rev => options[:rev], :rev_to => options[:rev_to], :path => options[:path],
|
||||
:change_id => options[:change_id], :attachment_id => options[:attachment_id],
|
||||
:changeset_id => options[:changeset_id]}, :class => 'icon icon-add')
|
||||
|
||||
html << link if link
|
||||
|
||||
html
|
||||
end
|
||||
end
|
@ -0,0 +1,175 @@
|
||||
# Code Review plugin for Redmine
|
||||
# Copyright (C) 2009-2012 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.
|
||||
class CodeReview < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
unloadable
|
||||
belongs_to :project
|
||||
belongs_to :change
|
||||
belongs_to :issue
|
||||
belongs_to :updated_by, :class_name => 'User', :foreign_key => 'updated_by_id'
|
||||
belongs_to :attachment
|
||||
|
||||
validates_presence_of :project_id, :user_id, :updated_by_id, :issue,
|
||||
:subject, :action_type, :line
|
||||
|
||||
STATUS_OPEN = 0
|
||||
STATUS_CLOSED = 1
|
||||
|
||||
safe_attributes 'change_id', 'subject', 'line', 'parent_id', 'comment', 'status_id'
|
||||
|
||||
def before_create
|
||||
issue = Issue.new unless issue
|
||||
end
|
||||
|
||||
def is_closed?
|
||||
issue.closed?
|
||||
#self.root.status == STATUS_CLOSED
|
||||
end
|
||||
|
||||
def close
|
||||
issue.status = IssueStatus.find(5)
|
||||
#self.root.status = STATUS_CLOSED
|
||||
end
|
||||
|
||||
def reopen
|
||||
issue.status = IssueStatus.find(1)
|
||||
#self.root.status = STATUS_OPEN
|
||||
end
|
||||
|
||||
def committer
|
||||
return changeset.author if changeset
|
||||
end
|
||||
|
||||
def path
|
||||
begin
|
||||
return file_path if file_path
|
||||
return @path if @path
|
||||
if attachment_id
|
||||
@path = attachment.filename
|
||||
return @path
|
||||
end
|
||||
repository = changeset.repository
|
||||
url = repository.url
|
||||
root_url = repository.root_url
|
||||
if (url == nil || root_url == nil)
|
||||
@path = change.path
|
||||
return @path
|
||||
end
|
||||
rootpath = url[root_url.length, url.length - root_url.length]
|
||||
if rootpath == '/' || rootpath.blank?
|
||||
@path = change.path
|
||||
else
|
||||
@path = change.path[rootpath.length, change.path.length - rootpath.length]
|
||||
end
|
||||
rescue => ex
|
||||
return ex.to_s
|
||||
end
|
||||
end
|
||||
|
||||
def revision
|
||||
return rev if rev
|
||||
changeset.revision if changeset
|
||||
end
|
||||
|
||||
def changeset
|
||||
@changeset ||= change.changeset if change
|
||||
end
|
||||
|
||||
def repository
|
||||
@repository ||= changeset.repository if changeset
|
||||
end
|
||||
|
||||
def repository_identifier
|
||||
return nil unless repository
|
||||
@repository_identifier ||= repository.identifier_param
|
||||
end
|
||||
|
||||
def comment=(str)
|
||||
issue.description = str if issue
|
||||
end
|
||||
|
||||
def comment
|
||||
issue.description if issue
|
||||
end
|
||||
|
||||
def before_save
|
||||
issue.project_id = project_id unless issue.project_id
|
||||
end
|
||||
|
||||
def validate
|
||||
unless issue.validate
|
||||
false
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def user=(u)
|
||||
issue.author = u
|
||||
end
|
||||
|
||||
def user_id=(id)
|
||||
issue.author_id = id
|
||||
end
|
||||
|
||||
def user_id
|
||||
issue.author_id
|
||||
end
|
||||
|
||||
def user
|
||||
issue.author if issue
|
||||
end
|
||||
|
||||
def subject=(s)
|
||||
issue.subject = s
|
||||
end
|
||||
|
||||
def subject
|
||||
issue.subject
|
||||
end
|
||||
|
||||
def parent_id= (p)
|
||||
issue.parent_issue_id = p
|
||||
end
|
||||
|
||||
def parent_id
|
||||
issue.parent_issue_id
|
||||
end
|
||||
|
||||
def status_id=(s)
|
||||
issue.status_id = s
|
||||
end
|
||||
|
||||
def status_id
|
||||
issue.status_id
|
||||
end
|
||||
|
||||
def open_assignment_issues(user_id)
|
||||
issues = []
|
||||
assignments = []
|
||||
assignments = change.code_review_assignments if change
|
||||
assignments = assignments + changeset.code_review_assignments if changeset
|
||||
assignments = assignments + attachment.code_review_assignments if attachment
|
||||
|
||||
assignments.each {|assignment|
|
||||
unless assignment.is_closed?
|
||||
issues << assignment.issue if user_id == assignment.issue.assigned_to_id
|
||||
end
|
||||
}
|
||||
|
||||
issues
|
||||
end
|
||||
end
|
@ -0,0 +1,80 @@
|
||||
# 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.
|
||||
|
||||
class CodeReviewAssignment < ActiveRecord::Base
|
||||
unloadable
|
||||
belongs_to :issue
|
||||
belongs_to :change
|
||||
belongs_to :changeset
|
||||
belongs_to :attachment
|
||||
validates_presence_of :issue_id
|
||||
|
||||
def is_closed?
|
||||
issue.closed?
|
||||
end
|
||||
|
||||
def path
|
||||
file_path
|
||||
end
|
||||
|
||||
def revision
|
||||
return rev if rev
|
||||
changeset.revision if changeset
|
||||
end
|
||||
|
||||
def repository
|
||||
@repository ||= change.changeset.repository if change
|
||||
@repository ||= changeset.repository if changeset
|
||||
@repository
|
||||
end
|
||||
|
||||
def repository_identifier
|
||||
return nil unless repository
|
||||
@repository_identifier ||= repository.identifier_param if repository.respond_to?("identifier_param")
|
||||
end
|
||||
|
||||
def self.create_with_changeset(changeset)
|
||||
project = changeset.project
|
||||
setting = CodeReviewProjectSetting.find_or_create(project)
|
||||
auto_assign = setting.auto_assign_settings
|
||||
assignment = CodeReviewAssignment.new
|
||||
issue = Issue.new
|
||||
issue.subject = auto_assign.subject
|
||||
issue.subject = l(:code_review_requrest) if issue.subject.blank?
|
||||
issue.subject = issue.subject.sub("$REV" , changeset.revision)
|
||||
issue.subject = issue.subject.sub("$COMMENTS" , changeset.comments.split(//u)[0..60].join) unless changeset.comments.blank?
|
||||
issue.tracker_id = setting.assignment_tracker_id
|
||||
issue.project = project
|
||||
issue.author = User.find(auto_assign.author_id)
|
||||
issue.assigned_to_id = auto_assign.select_assign_to(project, changeset.user)
|
||||
issue.description = auto_assign.description
|
||||
issue.description = issue.description.sub("$REV" , changeset.revision) unless issue.description.blank?
|
||||
issue.description = issue.description.sub("$COMMENTS" , changeset.comments) unless changeset.comments.blank?
|
||||
|
||||
issue.save!
|
||||
|
||||
assignment.issue_id = issue.id
|
||||
assignment.changeset_id = changeset.id
|
||||
assignment.save!
|
||||
assignment
|
||||
end
|
||||
|
||||
|
||||
def diff_all
|
||||
path.blank?
|
||||
end
|
||||
end
|
@ -0,0 +1,77 @@
|
||||
# Code Review plugin for Redmine
|
||||
# Copyright (C) 2009-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.
|
||||
class CodeReviewProjectSetting < ActiveRecord::Base
|
||||
unloadable
|
||||
include Redmine::SafeAttributes
|
||||
include CodeReviewAutoAssignSettings
|
||||
|
||||
belongs_to :project
|
||||
belongs_to :tracker
|
||||
belongs_to :assignment_tracker, :class_name => 'Tracker'
|
||||
|
||||
validates_presence_of :project_id
|
||||
validates_presence_of :tracker_id
|
||||
validates_presence_of :assignment_tracker_id
|
||||
|
||||
before_save :set_assignment_settings
|
||||
|
||||
safe_attributes 'tracker_id', 'assignment_tracker_id', 'hide_code_review_tab', 'auto_relation', 'tracker_in_review_dialog'
|
||||
|
||||
AUTORELATION_TYPE_NONE = 0
|
||||
AUTORELATION_TYPE_RELATES = 1
|
||||
AUTORELATION_TYPE_BLOCKS = 2
|
||||
|
||||
def self.find_or_create(project)
|
||||
setting = CodeReviewProjectSetting.find_by_project_id(project.id)
|
||||
unless setting
|
||||
setting = CodeReviewProjectSetting.new
|
||||
setting.project_id = project.id
|
||||
return setting if project.trackers.length == 0
|
||||
setting.tracker = project.trackers[0]
|
||||
setting.assignment_tracker = project.trackers[0]
|
||||
setting.save!
|
||||
end
|
||||
setting
|
||||
end
|
||||
|
||||
def auto_assign_settings
|
||||
@auto_assign_settings ||= AutoAssignSettings.load(auto_assign)
|
||||
end
|
||||
|
||||
def auto_assign_settings=(settings)
|
||||
@auto_assign_settings = settings
|
||||
end
|
||||
|
||||
def issue_relation_type
|
||||
return IssueRelation::TYPE_RELATES if auto_relation == CodeReviewProjectSetting::AUTORELATION_TYPE_RELATES
|
||||
return IssueRelation::TYPE_BLOCKS if auto_relation == CodeReviewProjectSetting::AUTORELATION_TYPE_BLOCKS
|
||||
return nil
|
||||
end
|
||||
|
||||
def auto_relation?
|
||||
issue_relation_type != nil
|
||||
end
|
||||
|
||||
private
|
||||
def set_assignment_settings
|
||||
if auto_assign_settings
|
||||
self.auto_assign = auto_assign_settings.to_s
|
||||
else
|
||||
self.auto_assign = nil
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,50 @@
|
||||
# Code Review plugin for Redmine
|
||||
# Copyright (C) 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.
|
||||
class CodeReviewUserSetting < ActiveRecord::Base
|
||||
unloadable
|
||||
belongs_to :user
|
||||
|
||||
validates_presence_of :user_id
|
||||
validates_presence_of :mail_notification
|
||||
validates_uniqueness_of :user_id
|
||||
|
||||
NOTIFCIATION_NONE = 0
|
||||
NOTIFICATION_INVOLVED_IN = 1
|
||||
NOTIFICATION_ALL = 2
|
||||
|
||||
def CodeReviewUserSetting.find_or_create(uid)
|
||||
setting = CodeReviewUserSetting.find_by_user_id(uid)
|
||||
return setting if setting
|
||||
setting = CodeReviewUserSetting.new
|
||||
setting.user_id = uid
|
||||
setting.mail_notification = NOTIFICATION_INVOLVED_IN
|
||||
setting.save
|
||||
return setting
|
||||
end
|
||||
|
||||
def mail_notification_none?
|
||||
mail_notification == NOTIFCIATION_NONE
|
||||
end
|
||||
|
||||
def mail_notification_involved_in?
|
||||
mail_notification == NOTIFICATION_INVOLVED_IN
|
||||
end
|
||||
|
||||
def mail_notification_all?
|
||||
mail_notification == NOTIFICATION_ALL
|
||||
end
|
||||
end
|
@ -0,0 +1,122 @@
|
||||
# Code Review plugin for Redmine
|
||||
# Copyright (C) 2009 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.
|
||||
|
||||
class ReviewMailer < Mailer
|
||||
|
||||
def review_add(project, review)
|
||||
redmine_headers 'Project' => review.project.identifier,
|
||||
'Review-Id' => review.id,
|
||||
'Review-Author' => review.user.login
|
||||
|
||||
recipients get_mail_addresses(review)
|
||||
|
||||
subject "[#{review.project.name} - #{l(:label_review_new)} - #{l(:label_review)}##{review.id}] "
|
||||
review_url = url_for(:controller => 'code_review', :action => 'show', :id => project, :review_id => review.id)
|
||||
|
||||
body :review => review, :review_url => review_url
|
||||
|
||||
return if (l(:this_is_checking_for_before_rails_2_2_2) == 'this_is_checking_for_before_rails_2_2_2')
|
||||
# 何故かrails 2.2 以後は以下の処理が必要
|
||||
|
||||
content_type "multipart/alternative"
|
||||
|
||||
part "text/plain" do |p|
|
||||
p.body = render_message("review_add.text.plain.erb", :body => body, :review=>review, :review_url => review_url)
|
||||
end
|
||||
|
||||
part "text/html" do |p|
|
||||
p.body = render_message("review_add.text.html.erb", :body => body, :review=>review, :review_url => review_url)
|
||||
end
|
||||
end
|
||||
|
||||
def review_reply(project, review)
|
||||
redmine_headers 'Project' => review.project.identifier,
|
||||
'Review-Id' => review.id,
|
||||
'Review-Author' => review.user.login
|
||||
|
||||
recipients recipients get_mail_addresses(review)
|
||||
|
||||
subject "[#{review.project.name} - Updated - #{l(:label_review)}##{review.root.id}] "
|
||||
review_url = url_for(:controller => 'code_review', :action => 'show', :id => project, :review_id => review.root.id)
|
||||
body :review => review, :review_url => review_url
|
||||
|
||||
return if (l(:this_is_checking_for_before_rails_2_2_2) == 'this_is_checking_for_before_rails_2_2_2')
|
||||
# 何故かrails 2.2 以後は以下の処理が必要
|
||||
|
||||
content_type "multipart/alternative"
|
||||
|
||||
part "text/plain" do |p|
|
||||
p.body = render_message("review_reply.text.plain.erb", :body => body, :review=>review, :review_url => review_url)
|
||||
end
|
||||
|
||||
part "text/html" do |p|
|
||||
p.body = render_message("review_reply.text.html.erb", :body => body, :review=>review, :review_url => review_url)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def review_status_changed(project, review)
|
||||
redmine_headers 'Project' => review.project.identifier,
|
||||
'Review-Id' => review.id,
|
||||
'Review-Author' => review.user.login
|
||||
|
||||
recipients recipients get_mail_addresses(review)
|
||||
|
||||
new_status = l(:label_review_open) if review.status_changed_to == CodeReview::STATUS_OPEN
|
||||
new_status = l(:label_review_closed) if review.status_changed_to == CodeReview::STATUS_CLOSED
|
||||
|
||||
subject "[#{review.project.name} - Updated - #{l(:label_review)}##{review.root.id}] Status changed to #{new_status}."
|
||||
review_url = url_for(:controller => 'code_review', :action => 'show', :id => project, :review_id => review.root.id)
|
||||
|
||||
body :review => review, :review_url => review_url
|
||||
|
||||
return if (l(:this_is_checking_for_before_rails_2_2_2) == 'this_is_checking_for_before_rails_2_2_2')
|
||||
# 何故かrails 2.2 以後は以下の処理が必要
|
||||
|
||||
content_type "multipart/alternative"
|
||||
|
||||
part "text/plain" do |p|
|
||||
p.body = render_message("review_status_changed.text.plain.erb", :body => body, :review=>review, :review_url => review_url)
|
||||
end
|
||||
|
||||
part "text/html" do |p|
|
||||
p.body = render_message("review_status_changed.text.html.erb", :body => body, :review=>review, :review_url => review_url)
|
||||
end
|
||||
end
|
||||
|
||||
def get_mail_addresses(review)
|
||||
mail_addresses = []
|
||||
review.root.users_for_notification.each{|u|
|
||||
mail_addresses << u.mail
|
||||
}
|
||||
committer = review.change.changeset.user
|
||||
if committer
|
||||
setting = CodeReviewUserSetting.find_or_create(committer.id)
|
||||
mail_addresses << committer.mail if setting and !setting.mail_notification_none?
|
||||
end
|
||||
|
||||
review.project.members.each{|member|
|
||||
user = member.user
|
||||
setting = CodeReviewUserSetting.find_or_create(user.id)
|
||||
next unless setting
|
||||
mail_addresses << user.mail if setting.mail_notification_all?
|
||||
}
|
||||
mail_addresses.compact.uniq
|
||||
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,27 @@
|
||||
<%
|
||||
# Code Review plugin for Redmine
|
||||
# Copyright (C) 2009 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.
|
||||
-%>
|
||||
<%= javascript_tag do %>
|
||||
|
||||
var line = <%= @review.line %>;
|
||||
var review_id = <%= @review.id %>;
|
||||
var file_count = <%= @review.file_count %>;
|
||||
hideForm();
|
||||
setShowReviewButton(line, review_id, false, file_count);
|
||||
|
||||
<% end %>
|
@ -0,0 +1,82 @@
|
||||
<%
|
||||
# Code Review plugin for Redmine
|
||||
# Copyright (C) 2010 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.
|
||||
-%>
|
||||
|
||||
<%
|
||||
is_target = false
|
||||
|
||||
if project and controller and project.module_enabled?(:code_review)
|
||||
is_target = true
|
||||
is_target = false unless User.current.allowed_to?({:controller => 'code_review', :action => 'update_diff_view'}, project)
|
||||
setting = CodeReviewProjectSetting.find(:first, :conditions => ['project_id = ?', project.id])
|
||||
is_target = false unless setting
|
||||
is_target = false if(setting && setting.tracker_id == nil)
|
||||
action_name = controller.action_name
|
||||
is_target = false unless action_name
|
||||
is_target = false unless (controller.class.name == 'RepositoriesController' or controller.class.name == 'AttachmentsController')
|
||||
if (is_target == true)
|
||||
context = {:project => project, :controller => controller, :requrest => request}
|
||||
%>
|
||||
<% if (controller.class.name == 'AttachmentsController') %>
|
||||
<%= render :partial => 'code_review/change_attachement_view', :locals => context %>
|
||||
<% elsif (action_name == 'show' or action_name == 'revisions') %>
|
||||
<%= render :partial => 'code_review/change_repository_view', :locals => context %>
|
||||
<% elsif (action_name == 'revision') %>
|
||||
<%= render :partial => 'code_review/change_revision_view', :locals => context %>
|
||||
<% elsif (action_name == 'diff' or action_name == 'entry' or action_name == 'annotate')%>
|
||||
<%if (controller.params[:rev].blank? or controller.params[:rev] == 'master')%>
|
||||
<%= render :partial => 'code_review/change_entry_norevision_view', :locals => context %>
|
||||
<% else
|
||||
changeset = @repository.find_changeset_by_name(controller.params[:rev])
|
||||
%>
|
||||
<% unless changeset %>
|
||||
<%= render :partial => 'code_review/change_entry_norevision_view', :locals => context %>
|
||||
<% else
|
||||
parameters = request.parameters
|
||||
rev_to = parameters['rev_to'] unless parameters['rev_to'].blank?
|
||||
review_id = parameters['review_id']
|
||||
rev = parameters['rev']
|
||||
path = parameters['path']
|
||||
|
||||
|
||||
repository_id = @repository.identifier_param if @repository.respond_to?("identifier_param")
|
||||
url = url_for :controller => 'code_review', :action => 'update_diff_view', :id => project, :repository_id => repository_id
|
||||
%>
|
||||
<div id="code_review">
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('#code_review').load('<%=url%>', {
|
||||
rev: '<%=rev%>',
|
||||
path:'<%=path%>',
|
||||
review_id: '<%=review_id%>',
|
||||
action_type:'<%=action_name%>',
|
||||
rev_to: '<%=rev_to%>'});
|
||||
});
|
||||
</script>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%
|
||||
end
|
||||
end
|
||||
-%>
|
||||
|
||||
|
||||
|
@ -0,0 +1,35 @@
|
||||
<%
|
||||
# Code Review plugin for Redmine
|
||||
# Copyright (C) 2010-2012 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.
|
||||
-%>
|
||||
<%
|
||||
parameters = request.parameters
|
||||
id = parameters[:id].to_i
|
||||
attachment = Attachment.find(id)
|
||||
return '' unless attachment.is_text? or attachment.is_diff?
|
||||
review_id = parameters[:review_id] unless parameters[:review_id].blank?
|
||||
url = url_for :controller => 'code_review', :action => 'update_attachment_view', :id => project
|
||||
-%>
|
||||
<div id="code_review">
|
||||
<div id="review_comment"/>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('#code_review').load('<%=url%>', {'attachment_id': '<%=id%>', 'review_id': '<%=review_id%>'});
|
||||
});
|
||||
</script>
|
@ -0,0 +1,39 @@
|
||||
<%
|
||||
# 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.
|
||||
-%>
|
||||
<%
|
||||
parameters = request.parameters
|
||||
path = parameters['path']
|
||||
rev = parameters['rev']
|
||||
repository_id = @repository.identifier_param if @repository.respond_to?("identifier_param")
|
||||
unless path.blank? or path.empty?
|
||||
changesets = @repository.latest_changesets(path, rev, Setting.repository_log_display_limit.to_i)
|
||||
change = changesets[0]
|
||||
|
||||
if change
|
||||
link = link_to(l(:label_add_review), {:controller => 'code_review',
|
||||
:action => 'forward_to_revision', :id => project, :path => path, :rev => rev, :repository_id => repository_id},
|
||||
:class => 'icon icon-edit')
|
||||
%>
|
||||
|
||||
<script type="text/javascript">
|
||||
make_addreview_link('<%=project.name%>', '<%=link%>');
|
||||
</script>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
@ -0,0 +1,41 @@
|
||||
<%
|
||||
# Code Review plugin for Redmine
|
||||
# Copyright (C) 2010-2012 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.
|
||||
-%>
|
||||
<%
|
||||
|
||||
if @changesets
|
||||
changeset_ids = ''
|
||||
@changesets.each { |changeset|
|
||||
changeset_ids << changeset.revision
|
||||
changeset_ids << ','
|
||||
}
|
||||
|
||||
repository_id = @repository.identifier_param if @repository.respond_to?("identifier_param")
|
||||
url = url_for :controller => 'code_review', :action => 'update_revisions_view', :id => project, :repository_id => repository_id
|
||||
%>
|
||||
|
||||
<div id="code_review_revisions"></div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('#code_review_revisions').load('<%=url%>', {changeset_ids: '<%=raw changeset_ids%>'});
|
||||
});
|
||||
</script>
|
||||
|
||||
<% end %>
|
@ -0,0 +1,73 @@
|
||||
<%
|
||||
# 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'
|
||||
%>
|
||||
<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>
|
||||
|
||||
<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.relative_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 %>
|
@ -0,0 +1,84 @@
|
||||
<%
|
||||
# Code Review plugin for Redmine
|
||||
# Copyright (C) 2009 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.
|
||||
-%>
|
||||
<% for journal in journals %>
|
||||
|
||||
<!-- skip initial entry of code review creation -->
|
||||
<% if not journal.initial? %>
|
||||
|
||||
<!-- header and notes/comments -->
|
||||
<%
|
||||
header = <<-HTML
|
||||
<h4>
|
||||
#{authoring journal.created_at, journal.user, :label => :label_updated_time_by}
|
||||
#{content_tag('a', '', :name => "note-#{journal.anchor}")}
|
||||
</h4>
|
||||
|
||||
<div class="profile-wrap">
|
||||
#{avatar(journal.user, :size => "40")}
|
||||
</div>
|
||||
HTML
|
||||
|
||||
if not journal.notes.blank?
|
||||
if User.current.logged?
|
||||
editable = User.current.allowed_to?(:edit_issue_notes, journal.project)
|
||||
if journal.user == User.current
|
||||
editable ||= User.current.allowed_to?(:edit_own_issue_notes, journal.project)
|
||||
end
|
||||
end
|
||||
|
||||
links = [].tap do |l|
|
||||
if editable
|
||||
l << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes",
|
||||
{ :controller => 'journals', :action => 'edit', :id => journal },
|
||||
:title => l(:button_edit))
|
||||
end
|
||||
end
|
||||
|
||||
css_classes = "wiki"
|
||||
css_classes << " editable" if editable
|
||||
|
||||
content = ''
|
||||
content << content_tag('div', links.join(' '), :class => 'contextual') unless links.empty?
|
||||
content << textilizable(journal, :notes)
|
||||
|
||||
header << content_tag("div", content, :id => "journal-#{journal.id}-notes", :class => css_classes)
|
||||
end
|
||||
%>
|
||||
|
||||
<!-- details such as attribute changes -->
|
||||
<%
|
||||
details = ''
|
||||
if journal.details.any?
|
||||
content = journal.details.collect do |detail|
|
||||
if d = journal.render_detail(detail)
|
||||
content_tag("li", d)
|
||||
end
|
||||
end.compact.join(' ')
|
||||
|
||||
details = content_tag("ul", content, :class => "details journal-attributes") unless content.empty?
|
||||
end
|
||||
%>
|
||||
|
||||
<!-- output HTML code -->
|
||||
<%= content_tag "div", "#{header}#{details}",
|
||||
{ :id => "change-#{journal.id}", :class => journal.css_classes } %>
|
||||
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue