-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.rb
93 lines (79 loc) · 3.62 KB
/
init.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Code Review plugin for Redmine
# Copyright (C) 2009-2017 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.
require 'redmine'
begin
require 'config/initializers/session_store.rb'
rescue LoadError
end
require 'gravatar'
require 'code_review_application_hooks'
require 'code_review_change_patch'
require 'code_review_changeset_patch'
require 'code_review_issue_patch'
require 'code_review_issue_hooks'
require 'code_review_projects_helper_patch'
require 'code_review_attachment_patch'
Rails.configuration.to_prepare do
unless Change.included_modules.include? CodeReviewChangePatch
Change.send(:include, CodeReviewChangePatch)
end
unless Changeset.included_modules.include? CodeReviewChangesetPatch
Changeset.send(:include, CodeReviewChangesetPatch)
end
unless Issue.included_modules.include? CodeReviewIssuePatch
Issue.send(:include, CodeReviewIssuePatch)
end
unless ProjectsHelper.included_modules.include? CodeReviewProjectsHelperPatch
ProjectsHelper.send(:include, CodeReviewProjectsHelperPatch)
end
unless Attachment.included_modules.include? CodeReviewAttachmentPatch
Attachment.send(:include, CodeReviewAttachmentPatch)
end
end
Redmine::Plugin.register :redmine_code_review do
name 'Redmine Code Review plugin'
author 'Haruyuki Iida'
author_url 'http://twitter.com/haru_iida'
url "http://www.r-labs.org/projects/show/codereview" if respond_to?(:url)
description 'This is a Code Review plugin for Redmine'
version '0.9.0'
requires_redmine :version_or_higher => '3.4.0'
project_module :code_review do
permission :view_code_review, {:code_review => [:update_diff_view, :update_attachment_view, :update_revisions_view, :index, :show]}, {:read => true}
permission :add_code_review, {:code_review => [:new, :reply, :forward_to_revision, :preview]}, :require => :member
permission :edit_code_review, {:code_review => [:update]}, :require => :member
permission :delete_code_review, {:code_review => [:destroy]}, :require => :member
permission :assign_code_review, {:code_review => [:assign]}, :require => :member
permission :code_review_setting, {:code_review_settings => [:show, :update, :add_filter, :edit_filter, :sort]}, :require => :member
end
menu :project_menu, :code_review, { :controller => 'code_review', :action => 'index' }, :caption => :code_reviews,
:if => Proc.new{|project|
setting = CodeReviewProjectSetting.find_or_create(project)
project.repository != nil and setting and !setting.hide_code_review_tab
}, :after => :repository
Redmine::WikiFormatting::Macros.register do
desc "This is my macro link to code review"
macro :review do |obj, args|
return nil if args.length == 0
review_id = args[0].to_i
return nil if review_id == 0
review = CodeReview.find(review_id)
return nil unless review
link_to(l(:label_review) + '#' + review.id.to_s, :controller => 'code_review', :action => 'show', :id => review.project, :review_id => review.id)
end
end
end