@@ -1,60 +1,82 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class NewsController < ApplicationController |
|
18 | class NewsController < ApplicationController | |
19 | layout 'base' |
|
19 | layout 'base' | |
20 | before_filter :find_project, :authorize |
|
20 | before_filter :find_project, :authorize, :except => :index | |
|
21 | before_filter :find_optional_project, :only => :index | |||
|
22 | accept_key_auth :index | |||
|
23 | ||||
|
24 | def index | |||
|
25 | @news_pages, @newss = paginate :news, | |||
|
26 | :per_page => 10, | |||
|
27 | :conditions => (@project ? {:project_id => @project.id} : Project.visible_by(User.current)), | |||
|
28 | :include => [:author, :project], | |||
|
29 | :order => "#{News.table_name}.created_on DESC" | |||
|
30 | respond_to do |format| | |||
|
31 | format.html { render :layout => false if request.xhr? } | |||
|
32 | format.atom { render_feed(@newss, :title => (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}") } | |||
|
33 | end | |||
|
34 | end | |||
21 |
|
35 | |||
22 | def show |
|
36 | def show | |
23 | end |
|
37 | end | |
24 |
|
38 | |||
25 | def edit |
|
39 | def edit | |
26 | if request.post? and @news.update_attributes(params[:news]) |
|
40 | if request.post? and @news.update_attributes(params[:news]) | |
27 | flash[:notice] = l(:notice_successful_update) |
|
41 | flash[:notice] = l(:notice_successful_update) | |
28 | redirect_to :action => 'show', :id => @news |
|
42 | redirect_to :action => 'show', :id => @news | |
29 | end |
|
43 | end | |
30 | end |
|
44 | end | |
31 |
|
45 | |||
32 | def add_comment |
|
46 | def add_comment | |
33 | @comment = Comment.new(params[:comment]) |
|
47 | @comment = Comment.new(params[:comment]) | |
34 | @comment.author = logged_in_user |
|
48 | @comment.author = logged_in_user | |
35 | if @news.comments << @comment |
|
49 | if @news.comments << @comment | |
36 | flash[:notice] = l(:label_comment_added) |
|
50 | flash[:notice] = l(:label_comment_added) | |
37 | redirect_to :action => 'show', :id => @news |
|
51 | redirect_to :action => 'show', :id => @news | |
38 | else |
|
52 | else | |
39 | render :action => 'show' |
|
53 | render :action => 'show' | |
40 | end |
|
54 | end | |
41 | end |
|
55 | end | |
42 |
|
56 | |||
43 | def destroy_comment |
|
57 | def destroy_comment | |
44 | @news.comments.find(params[:comment_id]).destroy |
|
58 | @news.comments.find(params[:comment_id]).destroy | |
45 | redirect_to :action => 'show', :id => @news |
|
59 | redirect_to :action => 'show', :id => @news | |
46 | end |
|
60 | end | |
47 |
|
61 | |||
48 | def destroy |
|
62 | def destroy | |
49 | @news.destroy |
|
63 | @news.destroy | |
50 |
redirect_to |
|
64 | redirect_to :action => 'index', :project_id => @project | |
51 | end |
|
65 | end | |
52 |
|
66 | |||
53 | private |
|
67 | private | |
54 | def find_project |
|
68 | def find_project | |
55 | @news = News.find(params[:id]) |
|
69 | @news = News.find(params[:id]) | |
56 | @project = @news.project |
|
70 | @project = @news.project | |
57 | rescue ActiveRecord::RecordNotFound |
|
71 | rescue ActiveRecord::RecordNotFound | |
58 | render_404 |
|
72 | render_404 | |
59 |
end |
|
73 | end | |
|
74 | ||||
|
75 | def find_optional_project | |||
|
76 | return true unless params[:project_id] | |||
|
77 | @project = Project.find(params[:project_id]) | |||
|
78 | authorize | |||
|
79 | rescue ActiveRecord::RecordNotFound | |||
|
80 | render_404 | |||
|
81 | end | |||
60 | end |
|
82 | end |
@@ -1,555 +1,545 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class ProjectsController < ApplicationController |
|
18 | class ProjectsController < ApplicationController | |
19 | layout 'base' |
|
19 | layout 'base' | |
20 | before_filter :find_project, :except => [ :index, :list, :add ] |
|
20 | before_filter :find_project, :except => [ :index, :list, :add ] | |
21 | before_filter :authorize, :except => [ :index, :list, :add, :archive, :unarchive, :destroy ] |
|
21 | before_filter :authorize, :except => [ :index, :list, :add, :archive, :unarchive, :destroy ] | |
22 | before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ] |
|
22 | before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ] | |
23 | accept_key_auth :activity, :calendar |
|
23 | accept_key_auth :activity, :calendar | |
24 |
|
24 | |||
25 | cache_sweeper :project_sweeper, :only => [ :add, :edit, :archive, :unarchive, :destroy ] |
|
25 | cache_sweeper :project_sweeper, :only => [ :add, :edit, :archive, :unarchive, :destroy ] | |
26 | cache_sweeper :issue_sweeper, :only => [ :add_issue ] |
|
26 | cache_sweeper :issue_sweeper, :only => [ :add_issue ] | |
27 | cache_sweeper :version_sweeper, :only => [ :add_version ] |
|
27 | cache_sweeper :version_sweeper, :only => [ :add_version ] | |
28 |
|
28 | |||
29 | helper :sort |
|
29 | helper :sort | |
30 | include SortHelper |
|
30 | include SortHelper | |
31 | helper :custom_fields |
|
31 | helper :custom_fields | |
32 | include CustomFieldsHelper |
|
32 | include CustomFieldsHelper | |
33 | helper :ifpdf |
|
33 | helper :ifpdf | |
34 | include IfpdfHelper |
|
34 | include IfpdfHelper | |
35 | helper :issues |
|
35 | helper :issues | |
36 | helper IssuesHelper |
|
36 | helper IssuesHelper | |
37 | helper :queries |
|
37 | helper :queries | |
38 | include QueriesHelper |
|
38 | include QueriesHelper | |
39 | helper :repositories |
|
39 | helper :repositories | |
40 | include RepositoriesHelper |
|
40 | include RepositoriesHelper | |
41 | include ProjectsHelper |
|
41 | include ProjectsHelper | |
42 |
|
42 | |||
43 | def index |
|
43 | def index | |
44 | list |
|
44 | list | |
45 | render :action => 'list' unless request.xhr? |
|
45 | render :action => 'list' unless request.xhr? | |
46 | end |
|
46 | end | |
47 |
|
47 | |||
48 | # Lists visible projects |
|
48 | # Lists visible projects | |
49 | def list |
|
49 | def list | |
50 | projects = Project.find :all, |
|
50 | projects = Project.find :all, | |
51 | :conditions => Project.visible_by(logged_in_user), |
|
51 | :conditions => Project.visible_by(logged_in_user), | |
52 | :include => :parent |
|
52 | :include => :parent | |
53 | @project_tree = projects.group_by {|p| p.parent || p} |
|
53 | @project_tree = projects.group_by {|p| p.parent || p} | |
54 | @project_tree.each_key {|p| @project_tree[p] -= [p]} |
|
54 | @project_tree.each_key {|p| @project_tree[p] -= [p]} | |
55 | end |
|
55 | end | |
56 |
|
56 | |||
57 | # Add a new project |
|
57 | # Add a new project | |
58 | def add |
|
58 | def add | |
59 | @custom_fields = IssueCustomField.find(:all) |
|
59 | @custom_fields = IssueCustomField.find(:all) | |
60 | @root_projects = Project.find(:all, :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}") |
|
60 | @root_projects = Project.find(:all, :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}") | |
61 | @project = Project.new(params[:project]) |
|
61 | @project = Project.new(params[:project]) | |
62 | @project.enabled_module_names = Redmine::AccessControl.available_project_modules |
|
62 | @project.enabled_module_names = Redmine::AccessControl.available_project_modules | |
63 | if request.get? |
|
63 | if request.get? | |
64 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) } |
|
64 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) } | |
65 | else |
|
65 | else | |
66 | @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] |
|
66 | @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] | |
67 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => (params[:custom_fields] ? params["custom_fields"][x.id.to_s] : nil)) } |
|
67 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => (params[:custom_fields] ? params["custom_fields"][x.id.to_s] : nil)) } | |
68 | @project.custom_values = @custom_values |
|
68 | @project.custom_values = @custom_values | |
69 | if @project.save |
|
69 | if @project.save | |
70 | @project.enabled_module_names = params[:enabled_modules] |
|
70 | @project.enabled_module_names = params[:enabled_modules] | |
71 | flash[:notice] = l(:notice_successful_create) |
|
71 | flash[:notice] = l(:notice_successful_create) | |
72 | redirect_to :controller => 'admin', :action => 'projects' |
|
72 | redirect_to :controller => 'admin', :action => 'projects' | |
73 | end |
|
73 | end | |
74 | end |
|
74 | end | |
75 | end |
|
75 | end | |
76 |
|
76 | |||
77 | # Show @project |
|
77 | # Show @project | |
78 | def show |
|
78 | def show | |
79 | @custom_values = @project.custom_values.find(:all, :include => :custom_field) |
|
79 | @custom_values = @project.custom_values.find(:all, :include => :custom_field) | |
80 | @members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role} |
|
80 | @members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role} | |
81 | @subprojects = @project.active_children |
|
81 | @subprojects = @project.active_children | |
82 | @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") |
|
82 | @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") | |
83 | @trackers = Tracker.find(:all, :order => 'position') |
|
83 | @trackers = Tracker.find(:all, :order => 'position') | |
84 | @open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN #{IssueStatus.table_name} ON #{IssueStatus.table_name}.id = #{Issue.table_name}.status_id", :conditions => ["project_id=? and #{IssueStatus.table_name}.is_closed=?", @project.id, false]) |
|
84 | @open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN #{IssueStatus.table_name} ON #{IssueStatus.table_name}.id = #{Issue.table_name}.status_id", :conditions => ["project_id=? and #{IssueStatus.table_name}.is_closed=?", @project.id, false]) | |
85 | @total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id]) |
|
85 | @total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id]) | |
86 | @total_hours = @project.time_entries.sum(:hours) |
|
86 | @total_hours = @project.time_entries.sum(:hours) | |
87 | @key = User.current.rss_key |
|
87 | @key = User.current.rss_key | |
88 | end |
|
88 | end | |
89 |
|
89 | |||
90 | def settings |
|
90 | def settings | |
91 | @root_projects = Project::find(:all, :conditions => ["parent_id IS NULL AND status = #{Project::STATUS_ACTIVE} AND id <> ?", @project.id]) |
|
91 | @root_projects = Project::find(:all, :conditions => ["parent_id IS NULL AND status = #{Project::STATUS_ACTIVE} AND id <> ?", @project.id]) | |
92 | @custom_fields = IssueCustomField.find(:all) |
|
92 | @custom_fields = IssueCustomField.find(:all) | |
93 | @issue_category ||= IssueCategory.new |
|
93 | @issue_category ||= IssueCategory.new | |
94 | @member ||= @project.members.new |
|
94 | @member ||= @project.members.new | |
95 | @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) } |
|
95 | @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) } | |
96 | @repository ||= @project.repository |
|
96 | @repository ||= @project.repository | |
97 | @wiki ||= @project.wiki |
|
97 | @wiki ||= @project.wiki | |
98 | end |
|
98 | end | |
99 |
|
99 | |||
100 | # Edit @project |
|
100 | # Edit @project | |
101 | def edit |
|
101 | def edit | |
102 | if request.post? |
|
102 | if request.post? | |
103 | @project.custom_fields = IssueCustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] |
|
103 | @project.custom_fields = IssueCustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] | |
104 | if params[:custom_fields] |
|
104 | if params[:custom_fields] | |
105 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) } |
|
105 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) } | |
106 | @project.custom_values = @custom_values |
|
106 | @project.custom_values = @custom_values | |
107 | end |
|
107 | end | |
108 | @project.attributes = params[:project] |
|
108 | @project.attributes = params[:project] | |
109 | if @project.save |
|
109 | if @project.save | |
110 | flash[:notice] = l(:notice_successful_update) |
|
110 | flash[:notice] = l(:notice_successful_update) | |
111 | redirect_to :action => 'settings', :id => @project |
|
111 | redirect_to :action => 'settings', :id => @project | |
112 | else |
|
112 | else | |
113 | settings |
|
113 | settings | |
114 | render :action => 'settings' |
|
114 | render :action => 'settings' | |
115 | end |
|
115 | end | |
116 | end |
|
116 | end | |
117 | end |
|
117 | end | |
118 |
|
118 | |||
119 | def modules |
|
119 | def modules | |
120 | @project.enabled_module_names = params[:enabled_modules] |
|
120 | @project.enabled_module_names = params[:enabled_modules] | |
121 | redirect_to :action => 'settings', :id => @project, :tab => 'modules' |
|
121 | redirect_to :action => 'settings', :id => @project, :tab => 'modules' | |
122 | end |
|
122 | end | |
123 |
|
123 | |||
124 | def archive |
|
124 | def archive | |
125 | @project.archive if request.post? && @project.active? |
|
125 | @project.archive if request.post? && @project.active? | |
126 | redirect_to :controller => 'admin', :action => 'projects' |
|
126 | redirect_to :controller => 'admin', :action => 'projects' | |
127 | end |
|
127 | end | |
128 |
|
128 | |||
129 | def unarchive |
|
129 | def unarchive | |
130 | @project.unarchive if request.post? && !@project.active? |
|
130 | @project.unarchive if request.post? && !@project.active? | |
131 | redirect_to :controller => 'admin', :action => 'projects' |
|
131 | redirect_to :controller => 'admin', :action => 'projects' | |
132 | end |
|
132 | end | |
133 |
|
133 | |||
134 | # Delete @project |
|
134 | # Delete @project | |
135 | def destroy |
|
135 | def destroy | |
136 | @project_to_destroy = @project |
|
136 | @project_to_destroy = @project | |
137 | if request.post? and params[:confirm] |
|
137 | if request.post? and params[:confirm] | |
138 | @project_to_destroy.destroy |
|
138 | @project_to_destroy.destroy | |
139 | redirect_to :controller => 'admin', :action => 'projects' |
|
139 | redirect_to :controller => 'admin', :action => 'projects' | |
140 | end |
|
140 | end | |
141 | # hide project in layout |
|
141 | # hide project in layout | |
142 | @project = nil |
|
142 | @project = nil | |
143 | end |
|
143 | end | |
144 |
|
144 | |||
145 | # Add a new issue category to @project |
|
145 | # Add a new issue category to @project | |
146 | def add_issue_category |
|
146 | def add_issue_category | |
147 | @category = @project.issue_categories.build(params[:category]) |
|
147 | @category = @project.issue_categories.build(params[:category]) | |
148 | if request.post? and @category.save |
|
148 | if request.post? and @category.save | |
149 | respond_to do |format| |
|
149 | respond_to do |format| | |
150 | format.html do |
|
150 | format.html do | |
151 | flash[:notice] = l(:notice_successful_create) |
|
151 | flash[:notice] = l(:notice_successful_create) | |
152 | redirect_to :action => 'settings', :tab => 'categories', :id => @project |
|
152 | redirect_to :action => 'settings', :tab => 'categories', :id => @project | |
153 | end |
|
153 | end | |
154 | format.js do |
|
154 | format.js do | |
155 | # IE doesn't support the replace_html rjs method for select box options |
|
155 | # IE doesn't support the replace_html rjs method for select box options | |
156 | render(:update) {|page| page.replace "issue_category_id", |
|
156 | render(:update) {|page| page.replace "issue_category_id", | |
157 | content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]') |
|
157 | content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]') | |
158 | } |
|
158 | } | |
159 | end |
|
159 | end | |
160 | end |
|
160 | end | |
161 | end |
|
161 | end | |
162 | end |
|
162 | end | |
163 |
|
163 | |||
164 | # Add a new version to @project |
|
164 | # Add a new version to @project | |
165 | def add_version |
|
165 | def add_version | |
166 | @version = @project.versions.build(params[:version]) |
|
166 | @version = @project.versions.build(params[:version]) | |
167 | if request.post? and @version.save |
|
167 | if request.post? and @version.save | |
168 | flash[:notice] = l(:notice_successful_create) |
|
168 | flash[:notice] = l(:notice_successful_create) | |
169 | redirect_to :action => 'settings', :tab => 'versions', :id => @project |
|
169 | redirect_to :action => 'settings', :tab => 'versions', :id => @project | |
170 | end |
|
170 | end | |
171 | end |
|
171 | end | |
172 |
|
172 | |||
173 | # Add a new document to @project |
|
173 | # Add a new document to @project | |
174 | def add_document |
|
174 | def add_document | |
175 | @document = @project.documents.build(params[:document]) |
|
175 | @document = @project.documents.build(params[:document]) | |
176 | if request.post? and @document.save |
|
176 | if request.post? and @document.save | |
177 | # Save the attachments |
|
177 | # Save the attachments | |
178 | params[:attachments].each { |a| |
|
178 | params[:attachments].each { |a| | |
179 | Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0 |
|
179 | Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0 | |
180 | } if params[:attachments] and params[:attachments].is_a? Array |
|
180 | } if params[:attachments] and params[:attachments].is_a? Array | |
181 | flash[:notice] = l(:notice_successful_create) |
|
181 | flash[:notice] = l(:notice_successful_create) | |
182 | Mailer.deliver_document_added(@document) if Setting.notified_events.include?('document_added') |
|
182 | Mailer.deliver_document_added(@document) if Setting.notified_events.include?('document_added') | |
183 | redirect_to :action => 'list_documents', :id => @project |
|
183 | redirect_to :action => 'list_documents', :id => @project | |
184 | end |
|
184 | end | |
185 | end |
|
185 | end | |
186 |
|
186 | |||
187 | # Show documents list of @project |
|
187 | # Show documents list of @project | |
188 | def list_documents |
|
188 | def list_documents | |
189 | @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category' |
|
189 | @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category' | |
190 | documents = @project.documents.find :all, :include => [:attachments, :category] |
|
190 | documents = @project.documents.find :all, :include => [:attachments, :category] | |
191 | case @sort_by |
|
191 | case @sort_by | |
192 | when 'date' |
|
192 | when 'date' | |
193 | @grouped = documents.group_by {|d| d.created_on.to_date } |
|
193 | @grouped = documents.group_by {|d| d.created_on.to_date } | |
194 | when 'title' |
|
194 | when 'title' | |
195 | @grouped = documents.group_by {|d| d.title.first.upcase} |
|
195 | @grouped = documents.group_by {|d| d.title.first.upcase} | |
196 | when 'author' |
|
196 | when 'author' | |
197 | @grouped = documents.select{|d| d.attachments.any?}.group_by {|d| d.attachments.last.author} |
|
197 | @grouped = documents.select{|d| d.attachments.any?}.group_by {|d| d.attachments.last.author} | |
198 | else |
|
198 | else | |
199 | @grouped = documents.group_by(&:category) |
|
199 | @grouped = documents.group_by(&:category) | |
200 | end |
|
200 | end | |
201 | render :layout => false if request.xhr? |
|
201 | render :layout => false if request.xhr? | |
202 | end |
|
202 | end | |
203 |
|
203 | |||
204 | # Add a new issue to @project |
|
204 | # Add a new issue to @project | |
205 | # The new issue will be created from an existing one if copy_from parameter is given |
|
205 | # The new issue will be created from an existing one if copy_from parameter is given | |
206 | def add_issue |
|
206 | def add_issue | |
207 | @issue = params[:copy_from] ? Issue.new.copy_from(params[:copy_from]) : Issue.new(params[:issue]) |
|
207 | @issue = params[:copy_from] ? Issue.new.copy_from(params[:copy_from]) : Issue.new(params[:issue]) | |
208 | @issue.project = @project |
|
208 | @issue.project = @project | |
209 | @issue.author = User.current |
|
209 | @issue.author = User.current | |
210 | @issue.tracker ||= Tracker.find(params[:tracker_id]) |
|
210 | @issue.tracker ||= Tracker.find(params[:tracker_id]) | |
211 |
|
211 | |||
212 | default_status = IssueStatus.default |
|
212 | default_status = IssueStatus.default | |
213 | unless default_status |
|
213 | unless default_status | |
214 | flash.now[:error] = 'No default issue status is defined. Please check your configuration (Go to "Administration -> Issue statuses").' |
|
214 | flash.now[:error] = 'No default issue status is defined. Please check your configuration (Go to "Administration -> Issue statuses").' | |
215 | render :nothing => true, :layout => true |
|
215 | render :nothing => true, :layout => true | |
216 | return |
|
216 | return | |
217 | end |
|
217 | end | |
218 | @issue.status = default_status |
|
218 | @issue.status = default_status | |
219 | @allowed_statuses = ([default_status] + default_status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker))if logged_in_user |
|
219 | @allowed_statuses = ([default_status] + default_status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker))if logged_in_user | |
220 |
|
220 | |||
221 | if request.get? |
|
221 | if request.get? | |
222 | @issue.start_date ||= Date.today |
|
222 | @issue.start_date ||= Date.today | |
223 | @custom_values = @issue.custom_values.empty? ? |
|
223 | @custom_values = @issue.custom_values.empty? ? | |
224 | @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) } : |
|
224 | @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) } : | |
225 | @issue.custom_values |
|
225 | @issue.custom_values | |
226 | else |
|
226 | else | |
227 | requested_status = IssueStatus.find_by_id(params[:issue][:status_id]) |
|
227 | requested_status = IssueStatus.find_by_id(params[:issue][:status_id]) | |
228 | # Check that the user is allowed to apply the requested status |
|
228 | # Check that the user is allowed to apply the requested status | |
229 | @issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status |
|
229 | @issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status | |
230 | @custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) } |
|
230 | @custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) } | |
231 | @issue.custom_values = @custom_values |
|
231 | @issue.custom_values = @custom_values | |
232 | if @issue.save |
|
232 | if @issue.save | |
233 | if params[:attachments] && params[:attachments].is_a?(Array) |
|
233 | if params[:attachments] && params[:attachments].is_a?(Array) | |
234 | # Save attachments |
|
234 | # Save attachments | |
235 | params[:attachments].each {|a| Attachment.create(:container => @issue, :file => a, :author => User.current) unless a.size == 0} |
|
235 | params[:attachments].each {|a| Attachment.create(:container => @issue, :file => a, :author => User.current) unless a.size == 0} | |
236 | end |
|
236 | end | |
237 | flash[:notice] = l(:notice_successful_create) |
|
237 | flash[:notice] = l(:notice_successful_create) | |
238 | Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added') |
|
238 | Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added') | |
239 | redirect_to :controller => 'issues', :action => 'index', :project_id => @project |
|
239 | redirect_to :controller => 'issues', :action => 'index', :project_id => @project | |
240 | return |
|
240 | return | |
241 | end |
|
241 | end | |
242 | end |
|
242 | end | |
243 | @priorities = Enumeration::get_values('IPRI') |
|
243 | @priorities = Enumeration::get_values('IPRI') | |
244 | end |
|
244 | end | |
245 |
|
245 | |||
246 | # Bulk edit issues |
|
246 | # Bulk edit issues | |
247 | def bulk_edit_issues |
|
247 | def bulk_edit_issues | |
248 | if request.post? |
|
248 | if request.post? | |
249 | status = params[:status_id].blank? ? nil : IssueStatus.find_by_id(params[:status_id]) |
|
249 | status = params[:status_id].blank? ? nil : IssueStatus.find_by_id(params[:status_id]) | |
250 | priority = params[:priority_id].blank? ? nil : Enumeration.find_by_id(params[:priority_id]) |
|
250 | priority = params[:priority_id].blank? ? nil : Enumeration.find_by_id(params[:priority_id]) | |
251 | assigned_to = params[:assigned_to_id].blank? ? nil : User.find_by_id(params[:assigned_to_id]) |
|
251 | assigned_to = params[:assigned_to_id].blank? ? nil : User.find_by_id(params[:assigned_to_id]) | |
252 | category = params[:category_id].blank? ? nil : @project.issue_categories.find_by_id(params[:category_id]) |
|
252 | category = params[:category_id].blank? ? nil : @project.issue_categories.find_by_id(params[:category_id]) | |
253 | fixed_version = params[:fixed_version_id].blank? ? nil : @project.versions.find_by_id(params[:fixed_version_id]) |
|
253 | fixed_version = params[:fixed_version_id].blank? ? nil : @project.versions.find_by_id(params[:fixed_version_id]) | |
254 | issues = @project.issues.find_all_by_id(params[:issue_ids]) |
|
254 | issues = @project.issues.find_all_by_id(params[:issue_ids]) | |
255 | unsaved_issue_ids = [] |
|
255 | unsaved_issue_ids = [] | |
256 | issues.each do |issue| |
|
256 | issues.each do |issue| | |
257 | journal = issue.init_journal(User.current, params[:notes]) |
|
257 | journal = issue.init_journal(User.current, params[:notes]) | |
258 | issue.priority = priority if priority |
|
258 | issue.priority = priority if priority | |
259 | issue.assigned_to = assigned_to if assigned_to || params[:assigned_to_id] == 'none' |
|
259 | issue.assigned_to = assigned_to if assigned_to || params[:assigned_to_id] == 'none' | |
260 | issue.category = category if category |
|
260 | issue.category = category if category | |
261 | issue.fixed_version = fixed_version if fixed_version |
|
261 | issue.fixed_version = fixed_version if fixed_version | |
262 | issue.start_date = params[:start_date] unless params[:start_date].blank? |
|
262 | issue.start_date = params[:start_date] unless params[:start_date].blank? | |
263 | issue.due_date = params[:due_date] unless params[:due_date].blank? |
|
263 | issue.due_date = params[:due_date] unless params[:due_date].blank? | |
264 | issue.done_ratio = params[:done_ratio] unless params[:done_ratio].blank? |
|
264 | issue.done_ratio = params[:done_ratio] unless params[:done_ratio].blank? | |
265 | # Don't save any change to the issue if the user is not authorized to apply the requested status |
|
265 | # Don't save any change to the issue if the user is not authorized to apply the requested status | |
266 | if (status.nil? || (issue.status.new_status_allowed_to?(status, current_role, issue.tracker) && issue.status = status)) && issue.save |
|
266 | if (status.nil? || (issue.status.new_status_allowed_to?(status, current_role, issue.tracker) && issue.status = status)) && issue.save | |
267 | # Send notification for each issue (if changed) |
|
267 | # Send notification for each issue (if changed) | |
268 | Mailer.deliver_issue_edit(journal) if journal.details.any? && Setting.notified_events.include?('issue_updated') |
|
268 | Mailer.deliver_issue_edit(journal) if journal.details.any? && Setting.notified_events.include?('issue_updated') | |
269 | else |
|
269 | else | |
270 | # Keep unsaved issue ids to display them in flash error |
|
270 | # Keep unsaved issue ids to display them in flash error | |
271 | unsaved_issue_ids << issue.id |
|
271 | unsaved_issue_ids << issue.id | |
272 | end |
|
272 | end | |
273 | end |
|
273 | end | |
274 | if unsaved_issue_ids.empty? |
|
274 | if unsaved_issue_ids.empty? | |
275 | flash[:notice] = l(:notice_successful_update) unless issues.empty? |
|
275 | flash[:notice] = l(:notice_successful_update) unless issues.empty? | |
276 | else |
|
276 | else | |
277 | flash[:error] = l(:notice_failed_to_save_issues, unsaved_issue_ids.size, issues.size, '#' + unsaved_issue_ids.join(', #')) |
|
277 | flash[:error] = l(:notice_failed_to_save_issues, unsaved_issue_ids.size, issues.size, '#' + unsaved_issue_ids.join(', #')) | |
278 | end |
|
278 | end | |
279 | redirect_to :controller => 'issues', :action => 'index', :project_id => @project |
|
279 | redirect_to :controller => 'issues', :action => 'index', :project_id => @project | |
280 | return |
|
280 | return | |
281 | end |
|
281 | end | |
282 | if current_role && User.current.allowed_to?(:change_issue_status, @project) |
|
282 | if current_role && User.current.allowed_to?(:change_issue_status, @project) | |
283 | # Find potential statuses the user could be allowed to switch issues to |
|
283 | # Find potential statuses the user could be allowed to switch issues to | |
284 | @available_statuses = Workflow.find(:all, :include => :new_status, |
|
284 | @available_statuses = Workflow.find(:all, :include => :new_status, | |
285 | :conditions => {:role_id => current_role.id}).collect(&:new_status).compact.uniq |
|
285 | :conditions => {:role_id => current_role.id}).collect(&:new_status).compact.uniq | |
286 | end |
|
286 | end | |
287 | render :update do |page| |
|
287 | render :update do |page| | |
288 | page.hide 'query_form' |
|
288 | page.hide 'query_form' | |
289 | page.replace_html 'bulk-edit', :partial => 'issues/bulk_edit_form' |
|
289 | page.replace_html 'bulk-edit', :partial => 'issues/bulk_edit_form' | |
290 | end |
|
290 | end | |
291 | end |
|
291 | end | |
292 |
|
292 | |||
293 | def move_issues |
|
293 | def move_issues | |
294 | @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids] |
|
294 | @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids] | |
295 | redirect_to :controller => 'issues', :action => 'index', :project_id => @project and return unless @issues |
|
295 | redirect_to :controller => 'issues', :action => 'index', :project_id => @project and return unless @issues | |
296 | @projects = [] |
|
296 | @projects = [] | |
297 | # find projects to which the user is allowed to move the issue |
|
297 | # find projects to which the user is allowed to move the issue | |
298 | User.current.memberships.each {|m| @projects << m.project if m.role.allowed_to?(:controller => 'projects', :action => 'move_issues')} |
|
298 | User.current.memberships.each {|m| @projects << m.project if m.role.allowed_to?(:controller => 'projects', :action => 'move_issues')} | |
299 | # issue can be moved to any tracker |
|
299 | # issue can be moved to any tracker | |
300 | @trackers = Tracker.find(:all) |
|
300 | @trackers = Tracker.find(:all) | |
301 | if request.post? and params[:new_project_id] and params[:new_tracker_id] |
|
301 | if request.post? and params[:new_project_id] and params[:new_tracker_id] | |
302 | new_project = Project.find_by_id(params[:new_project_id]) |
|
302 | new_project = Project.find_by_id(params[:new_project_id]) | |
303 | new_tracker = Tracker.find_by_id(params[:new_tracker_id]) |
|
303 | new_tracker = Tracker.find_by_id(params[:new_tracker_id]) | |
304 | @issues.each do |i| |
|
304 | @issues.each do |i| | |
305 | if new_project && i.project_id != new_project.id |
|
305 | if new_project && i.project_id != new_project.id | |
306 | # issue is moved to another project |
|
306 | # issue is moved to another project | |
307 | i.category = nil |
|
307 | i.category = nil | |
308 | i.fixed_version = nil |
|
308 | i.fixed_version = nil | |
309 | # delete issue relations |
|
309 | # delete issue relations | |
310 | i.relations_from.clear |
|
310 | i.relations_from.clear | |
311 | i.relations_to.clear |
|
311 | i.relations_to.clear | |
312 | i.project = new_project |
|
312 | i.project = new_project | |
313 | end |
|
313 | end | |
314 | if new_tracker |
|
314 | if new_tracker | |
315 | i.tracker = new_tracker |
|
315 | i.tracker = new_tracker | |
316 | end |
|
316 | end | |
317 | i.save |
|
317 | i.save | |
318 | end |
|
318 | end | |
319 | flash[:notice] = l(:notice_successful_update) |
|
319 | flash[:notice] = l(:notice_successful_update) | |
320 | redirect_to :controller => 'issues', :action => 'index', :project_id => @project |
|
320 | redirect_to :controller => 'issues', :action => 'index', :project_id => @project | |
321 | end |
|
321 | end | |
322 | end |
|
322 | end | |
323 |
|
323 | |||
324 | # Add a news to @project |
|
324 | # Add a news to @project | |
325 | def add_news |
|
325 | def add_news | |
326 | @news = News.new(:project => @project) |
|
326 | @news = News.new(:project => @project) | |
327 | if request.post? |
|
327 | if request.post? | |
328 | @news.attributes = params[:news] |
|
328 | @news.attributes = params[:news] | |
329 | @news.author_id = self.logged_in_user.id if self.logged_in_user |
|
329 | @news.author_id = self.logged_in_user.id if self.logged_in_user | |
330 | if @news.save |
|
330 | if @news.save | |
331 | flash[:notice] = l(:notice_successful_create) |
|
331 | flash[:notice] = l(:notice_successful_create) | |
332 | Mailer.deliver_news_added(@news) if Setting.notified_events.include?('news_added') |
|
332 | Mailer.deliver_news_added(@news) if Setting.notified_events.include?('news_added') | |
333 |
redirect_to :action => ' |
|
333 | redirect_to :controller => 'news', :action => 'index', :project_id => @project | |
334 | end |
|
334 | end | |
335 | end |
|
335 | end | |
336 | end |
|
336 | end | |
337 |
|
337 | |||
338 | # Show news list of @project |
|
|||
339 | def list_news |
|
|||
340 | @news_pages, @newss = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "#{News.table_name}.created_on DESC" |
|
|||
341 |
|
||||
342 | respond_to do |format| |
|
|||
343 | format.html { render :layout => false if request.xhr? } |
|
|||
344 | format.atom { render_feed(@newss, :title => "#{@project.name}: #{l(:label_news_plural)}") } |
|
|||
345 | end |
|
|||
346 | end |
|
|||
347 |
|
||||
348 | def add_file |
|
338 | def add_file | |
349 | if request.post? |
|
339 | if request.post? | |
350 | @version = @project.versions.find_by_id(params[:version_id]) |
|
340 | @version = @project.versions.find_by_id(params[:version_id]) | |
351 | # Save the attachments |
|
341 | # Save the attachments | |
352 | @attachments = [] |
|
342 | @attachments = [] | |
353 | params[:attachments].each { |file| |
|
343 | params[:attachments].each { |file| | |
354 | next unless file.size > 0 |
|
344 | next unless file.size > 0 | |
355 | a = Attachment.create(:container => @version, :file => file, :author => logged_in_user) |
|
345 | a = Attachment.create(:container => @version, :file => file, :author => logged_in_user) | |
356 | @attachments << a unless a.new_record? |
|
346 | @attachments << a unless a.new_record? | |
357 | } if params[:attachments] and params[:attachments].is_a? Array |
|
347 | } if params[:attachments] and params[:attachments].is_a? Array | |
358 | Mailer.deliver_attachments_added(@attachments) if !@attachments.empty? && Setting.notified_events.include?('file_added') |
|
348 | Mailer.deliver_attachments_added(@attachments) if !@attachments.empty? && Setting.notified_events.include?('file_added') | |
359 | redirect_to :controller => 'projects', :action => 'list_files', :id => @project |
|
349 | redirect_to :controller => 'projects', :action => 'list_files', :id => @project | |
360 | end |
|
350 | end | |
361 | @versions = @project.versions.sort |
|
351 | @versions = @project.versions.sort | |
362 | end |
|
352 | end | |
363 |
|
353 | |||
364 | def list_files |
|
354 | def list_files | |
365 | @versions = @project.versions.sort |
|
355 | @versions = @project.versions.sort | |
366 | end |
|
356 | end | |
367 |
|
357 | |||
368 | # Show changelog for @project |
|
358 | # Show changelog for @project | |
369 | def changelog |
|
359 | def changelog | |
370 | @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position') |
|
360 | @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position') | |
371 | retrieve_selected_tracker_ids(@trackers) |
|
361 | retrieve_selected_tracker_ids(@trackers) | |
372 | @versions = @project.versions.sort |
|
362 | @versions = @project.versions.sort | |
373 | end |
|
363 | end | |
374 |
|
364 | |||
375 | def roadmap |
|
365 | def roadmap | |
376 | @trackers = Tracker.find(:all, :conditions => ["is_in_roadmap=?", true], :order => 'position') |
|
366 | @trackers = Tracker.find(:all, :conditions => ["is_in_roadmap=?", true], :order => 'position') | |
377 | retrieve_selected_tracker_ids(@trackers) |
|
367 | retrieve_selected_tracker_ids(@trackers) | |
378 | @versions = @project.versions.sort |
|
368 | @versions = @project.versions.sort | |
379 | @versions = @versions.select {|v| !v.completed? } unless params[:completed] |
|
369 | @versions = @versions.select {|v| !v.completed? } unless params[:completed] | |
380 | end |
|
370 | end | |
381 |
|
371 | |||
382 | def activity |
|
372 | def activity | |
383 | if params[:year] and params[:year].to_i > 1900 |
|
373 | if params[:year] and params[:year].to_i > 1900 | |
384 | @year = params[:year].to_i |
|
374 | @year = params[:year].to_i | |
385 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 |
|
375 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 | |
386 | @month = params[:month].to_i |
|
376 | @month = params[:month].to_i | |
387 | end |
|
377 | end | |
388 | end |
|
378 | end | |
389 | @year ||= Date.today.year |
|
379 | @year ||= Date.today.year | |
390 | @month ||= Date.today.month |
|
380 | @month ||= Date.today.month | |
391 |
|
381 | |||
392 | case params[:format] |
|
382 | case params[:format] | |
393 | when 'atom' |
|
383 | when 'atom' | |
394 | # 30 last days |
|
384 | # 30 last days | |
395 | @date_from = Date.today - 30 |
|
385 | @date_from = Date.today - 30 | |
396 | @date_to = Date.today + 1 |
|
386 | @date_to = Date.today + 1 | |
397 | else |
|
387 | else | |
398 | # current month |
|
388 | # current month | |
399 | @date_from = Date.civil(@year, @month, 1) |
|
389 | @date_from = Date.civil(@year, @month, 1) | |
400 | @date_to = @date_from >> 1 |
|
390 | @date_to = @date_from >> 1 | |
401 | end |
|
391 | end | |
402 |
|
392 | |||
403 | @event_types = %w(issues news files documents wiki_pages changesets) |
|
393 | @event_types = %w(issues news files documents wiki_pages changesets) | |
404 | @event_types.delete('wiki_pages') unless @project.wiki |
|
394 | @event_types.delete('wiki_pages') unless @project.wiki | |
405 | @event_types.delete('changesets') unless @project.repository |
|
395 | @event_types.delete('changesets') unless @project.repository | |
406 | # only show what the user is allowed to view |
|
396 | # only show what the user is allowed to view | |
407 | @event_types = @event_types.select {|o| User.current.allowed_to?("view_#{o}".to_sym, @project)} |
|
397 | @event_types = @event_types.select {|o| User.current.allowed_to?("view_#{o}".to_sym, @project)} | |
408 |
|
398 | |||
409 | @scope = @event_types.select {|t| params["show_#{t}"]} |
|
399 | @scope = @event_types.select {|t| params["show_#{t}"]} | |
410 | # default events if none is specified in parameters |
|
400 | # default events if none is specified in parameters | |
411 | @scope = (@event_types - %w(wiki_pages))if @scope.empty? |
|
401 | @scope = (@event_types - %w(wiki_pages))if @scope.empty? | |
412 |
|
402 | |||
413 | @events = [] |
|
403 | @events = [] | |
414 |
|
404 | |||
415 | if @scope.include?('issues') |
|
405 | if @scope.include?('issues') | |
416 | @events += @project.issues.find(:all, :include => [:author, :tracker], :conditions => ["#{Issue.table_name}.created_on>=? and #{Issue.table_name}.created_on<=?", @date_from, @date_to] ) |
|
406 | @events += @project.issues.find(:all, :include => [:author, :tracker], :conditions => ["#{Issue.table_name}.created_on>=? and #{Issue.table_name}.created_on<=?", @date_from, @date_to] ) | |
417 | end |
|
407 | end | |
418 |
|
408 | |||
419 | if @scope.include?('news') |
|
409 | if @scope.include?('news') | |
420 | @events += @project.news.find(:all, :conditions => ["#{News.table_name}.created_on>=? and #{News.table_name}.created_on<=?", @date_from, @date_to], :include => :author ) |
|
410 | @events += @project.news.find(:all, :conditions => ["#{News.table_name}.created_on>=? and #{News.table_name}.created_on<=?", @date_from, @date_to], :include => :author ) | |
421 | end |
|
411 | end | |
422 |
|
412 | |||
423 | if @scope.include?('files') |
|
413 | if @scope.include?('files') | |
424 | @events += Attachment.find(:all, :select => "#{Attachment.table_name}.*", :joins => "LEFT JOIN #{Version.table_name} ON #{Version.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Version' and #{Version.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author ) |
|
414 | @events += Attachment.find(:all, :select => "#{Attachment.table_name}.*", :joins => "LEFT JOIN #{Version.table_name} ON #{Version.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Version' and #{Version.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author ) | |
425 | end |
|
415 | end | |
426 |
|
416 | |||
427 | if @scope.include?('documents') |
|
417 | if @scope.include?('documents') | |
428 | @events += @project.documents.find(:all, :conditions => ["#{Document.table_name}.created_on>=? and #{Document.table_name}.created_on<=?", @date_from, @date_to] ) |
|
418 | @events += @project.documents.find(:all, :conditions => ["#{Document.table_name}.created_on>=? and #{Document.table_name}.created_on<=?", @date_from, @date_to] ) | |
429 | @events += Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN #{Document.table_name} ON #{Document.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Document' and #{Document.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author ) |
|
419 | @events += Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN #{Document.table_name} ON #{Document.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Document' and #{Document.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author ) | |
430 | end |
|
420 | end | |
431 |
|
421 | |||
432 | if @scope.include?('wiki_pages') |
|
422 | if @scope.include?('wiki_pages') | |
433 | select = "#{WikiContent.versioned_table_name}.updated_on, #{WikiContent.versioned_table_name}.comments, " + |
|
423 | select = "#{WikiContent.versioned_table_name}.updated_on, #{WikiContent.versioned_table_name}.comments, " + | |
434 | "#{WikiContent.versioned_table_name}.#{WikiContent.version_column}, #{WikiPage.table_name}.title, " + |
|
424 | "#{WikiContent.versioned_table_name}.#{WikiContent.version_column}, #{WikiPage.table_name}.title, " + | |
435 | "#{WikiContent.versioned_table_name}.page_id, #{WikiContent.versioned_table_name}.author_id, " + |
|
425 | "#{WikiContent.versioned_table_name}.page_id, #{WikiContent.versioned_table_name}.author_id, " + | |
436 | "#{WikiContent.versioned_table_name}.id" |
|
426 | "#{WikiContent.versioned_table_name}.id" | |
437 | joins = "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " + |
|
427 | joins = "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " + | |
438 | "LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id " |
|
428 | "LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id " | |
439 | conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?", |
|
429 | conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?", | |
440 | @project.id, @date_from, @date_to] |
|
430 | @project.id, @date_from, @date_to] | |
441 |
|
431 | |||
442 | @events += WikiContent.versioned_class.find(:all, :select => select, :joins => joins, :conditions => conditions) |
|
432 | @events += WikiContent.versioned_class.find(:all, :select => select, :joins => joins, :conditions => conditions) | |
443 | end |
|
433 | end | |
444 |
|
434 | |||
445 | if @scope.include?('changesets') |
|
435 | if @scope.include?('changesets') | |
446 | @events += @project.repository.changesets.find(:all, :conditions => ["#{Changeset.table_name}.committed_on BETWEEN ? AND ?", @date_from, @date_to]) |
|
436 | @events += @project.repository.changesets.find(:all, :conditions => ["#{Changeset.table_name}.committed_on BETWEEN ? AND ?", @date_from, @date_to]) | |
447 | end |
|
437 | end | |
448 |
|
438 | |||
449 | @events_by_day = @events.group_by(&:event_date) |
|
439 | @events_by_day = @events.group_by(&:event_date) | |
450 |
|
440 | |||
451 | respond_to do |format| |
|
441 | respond_to do |format| | |
452 | format.html { render :layout => false if request.xhr? } |
|
442 | format.html { render :layout => false if request.xhr? } | |
453 | format.atom { render_feed(@events, :title => "#{@project.name}: #{l(:label_activity)}") } |
|
443 | format.atom { render_feed(@events, :title => "#{@project.name}: #{l(:label_activity)}") } | |
454 | end |
|
444 | end | |
455 | end |
|
445 | end | |
456 |
|
446 | |||
457 | def calendar |
|
447 | def calendar | |
458 | @trackers = Tracker.find(:all, :order => 'position') |
|
448 | @trackers = Tracker.find(:all, :order => 'position') | |
459 | retrieve_selected_tracker_ids(@trackers) |
|
449 | retrieve_selected_tracker_ids(@trackers) | |
460 |
|
450 | |||
461 | if params[:year] and params[:year].to_i > 1900 |
|
451 | if params[:year] and params[:year].to_i > 1900 | |
462 | @year = params[:year].to_i |
|
452 | @year = params[:year].to_i | |
463 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 |
|
453 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 | |
464 | @month = params[:month].to_i |
|
454 | @month = params[:month].to_i | |
465 | end |
|
455 | end | |
466 | end |
|
456 | end | |
467 | @year ||= Date.today.year |
|
457 | @year ||= Date.today.year | |
468 | @month ||= Date.today.month |
|
458 | @month ||= Date.today.month | |
469 | @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month) |
|
459 | @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month) | |
470 |
|
460 | |||
471 | events = [] |
|
461 | events = [] | |
472 | @project.issues_with_subprojects(params[:with_subprojects]) do |
|
462 | @project.issues_with_subprojects(params[:with_subprojects]) do | |
473 | events += Issue.find(:all, |
|
463 | events += Issue.find(:all, | |
474 | :include => [:tracker, :status, :assigned_to, :priority, :project], |
|
464 | :include => [:tracker, :status, :assigned_to, :priority, :project], | |
475 | :conditions => ["((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?)) AND #{Issue.table_name}.tracker_id IN (#{@selected_tracker_ids.join(',')})", @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt] |
|
465 | :conditions => ["((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?)) AND #{Issue.table_name}.tracker_id IN (#{@selected_tracker_ids.join(',')})", @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt] | |
476 | ) unless @selected_tracker_ids.empty? |
|
466 | ) unless @selected_tracker_ids.empty? | |
477 | end |
|
467 | end | |
478 | events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt]) |
|
468 | events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt]) | |
479 | @calendar.events = events |
|
469 | @calendar.events = events | |
480 |
|
470 | |||
481 | render :layout => false if request.xhr? |
|
471 | render :layout => false if request.xhr? | |
482 | end |
|
472 | end | |
483 |
|
473 | |||
484 | def gantt |
|
474 | def gantt | |
485 | @trackers = Tracker.find(:all, :order => 'position') |
|
475 | @trackers = Tracker.find(:all, :order => 'position') | |
486 | retrieve_selected_tracker_ids(@trackers) |
|
476 | retrieve_selected_tracker_ids(@trackers) | |
487 |
|
477 | |||
488 | if params[:year] and params[:year].to_i >0 |
|
478 | if params[:year] and params[:year].to_i >0 | |
489 | @year_from = params[:year].to_i |
|
479 | @year_from = params[:year].to_i | |
490 | if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12 |
|
480 | if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12 | |
491 | @month_from = params[:month].to_i |
|
481 | @month_from = params[:month].to_i | |
492 | else |
|
482 | else | |
493 | @month_from = 1 |
|
483 | @month_from = 1 | |
494 | end |
|
484 | end | |
495 | else |
|
485 | else | |
496 | @month_from ||= Date.today.month |
|
486 | @month_from ||= Date.today.month | |
497 | @year_from ||= Date.today.year |
|
487 | @year_from ||= Date.today.year | |
498 | end |
|
488 | end | |
499 |
|
489 | |||
500 | zoom = (params[:zoom] || User.current.pref[:gantt_zoom]).to_i |
|
490 | zoom = (params[:zoom] || User.current.pref[:gantt_zoom]).to_i | |
501 | @zoom = (zoom > 0 && zoom < 5) ? zoom : 2 |
|
491 | @zoom = (zoom > 0 && zoom < 5) ? zoom : 2 | |
502 | months = (params[:months] || User.current.pref[:gantt_months]).to_i |
|
492 | months = (params[:months] || User.current.pref[:gantt_months]).to_i | |
503 | @months = (months > 0 && months < 25) ? months : 6 |
|
493 | @months = (months > 0 && months < 25) ? months : 6 | |
504 |
|
494 | |||
505 | # Save gantt paramters as user preference (zoom and months count) |
|
495 | # Save gantt paramters as user preference (zoom and months count) | |
506 | if (User.current.logged? && (@zoom != User.current.pref[:gantt_zoom] || @months != User.current.pref[:gantt_months])) |
|
496 | if (User.current.logged? && (@zoom != User.current.pref[:gantt_zoom] || @months != User.current.pref[:gantt_months])) | |
507 | User.current.pref[:gantt_zoom], User.current.pref[:gantt_months] = @zoom, @months |
|
497 | User.current.pref[:gantt_zoom], User.current.pref[:gantt_months] = @zoom, @months | |
508 | User.current.preference.save |
|
498 | User.current.preference.save | |
509 | end |
|
499 | end | |
510 |
|
500 | |||
511 | @date_from = Date.civil(@year_from, @month_from, 1) |
|
501 | @date_from = Date.civil(@year_from, @month_from, 1) | |
512 | @date_to = (@date_from >> @months) - 1 |
|
502 | @date_to = (@date_from >> @months) - 1 | |
513 |
|
503 | |||
514 | @events = [] |
|
504 | @events = [] | |
515 | @project.issues_with_subprojects(params[:with_subprojects]) do |
|
505 | @project.issues_with_subprojects(params[:with_subprojects]) do | |
516 | @events += Issue.find(:all, |
|
506 | @events += Issue.find(:all, | |
517 | :order => "start_date, due_date", |
|
507 | :order => "start_date, due_date", | |
518 | :include => [:tracker, :status, :assigned_to, :priority, :project], |
|
508 | :include => [:tracker, :status, :assigned_to, :priority, :project], | |
519 | :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to] |
|
509 | :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to] | |
520 | ) unless @selected_tracker_ids.empty? |
|
510 | ) unless @selected_tracker_ids.empty? | |
521 | end |
|
511 | end | |
522 | @events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to]) |
|
512 | @events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to]) | |
523 | @events.sort! {|x,y| x.start_date <=> y.start_date } |
|
513 | @events.sort! {|x,y| x.start_date <=> y.start_date } | |
524 |
|
514 | |||
525 | if params[:format]=='pdf' |
|
515 | if params[:format]=='pdf' | |
526 | @options_for_rfpdf ||= {} |
|
516 | @options_for_rfpdf ||= {} | |
527 | @options_for_rfpdf[:file_name] = "#{@project.identifier}-gantt.pdf" |
|
517 | @options_for_rfpdf[:file_name] = "#{@project.identifier}-gantt.pdf" | |
528 | render :template => "projects/gantt.rfpdf", :layout => false |
|
518 | render :template => "projects/gantt.rfpdf", :layout => false | |
529 | elsif params[:format]=='png' && respond_to?('gantt_image') |
|
519 | elsif params[:format]=='png' && respond_to?('gantt_image') | |
530 | image = gantt_image(@events, @date_from, @months, @zoom) |
|
520 | image = gantt_image(@events, @date_from, @months, @zoom) | |
531 | image.format = 'PNG' |
|
521 | image.format = 'PNG' | |
532 | send_data(image.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "#{@project.identifier}-gantt.png") |
|
522 | send_data(image.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "#{@project.identifier}-gantt.png") | |
533 | else |
|
523 | else | |
534 | render :template => "projects/gantt.rhtml" |
|
524 | render :template => "projects/gantt.rhtml" | |
535 | end |
|
525 | end | |
536 | end |
|
526 | end | |
537 |
|
527 | |||
538 | private |
|
528 | private | |
539 | # Find project of id params[:id] |
|
529 | # Find project of id params[:id] | |
540 | # if not found, redirect to project list |
|
530 | # if not found, redirect to project list | |
541 | # Used as a before_filter |
|
531 | # Used as a before_filter | |
542 | def find_project |
|
532 | def find_project | |
543 | @project = Project.find(params[:id]) |
|
533 | @project = Project.find(params[:id]) | |
544 | rescue ActiveRecord::RecordNotFound |
|
534 | rescue ActiveRecord::RecordNotFound | |
545 | render_404 |
|
535 | render_404 | |
546 | end |
|
536 | end | |
547 |
|
537 | |||
548 | def retrieve_selected_tracker_ids(selectable_trackers) |
|
538 | def retrieve_selected_tracker_ids(selectable_trackers) | |
549 | if ids = params[:tracker_ids] |
|
539 | if ids = params[:tracker_ids] | |
550 | @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s } |
|
540 | @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s } | |
551 | else |
|
541 | else | |
552 | @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s } |
|
542 | @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s } | |
553 | end |
|
543 | end | |
554 | end |
|
544 | end | |
555 | end |
|
545 | end |
@@ -1,33 +1,34 | |||||
1 | <div class="contextual"> |
|
1 | <div class="contextual"> | |
2 |
<%= link_to_if_authorized |
|
2 | <%= link_to_if_authorized(l(:label_news_new), | |
3 | {:controller => 'projects', :action => 'add_news', :id => @project}, |
|
3 | {:controller => 'projects', :action => 'add_news', :id => @project}, | |
4 | :class => 'icon icon-add', |
|
4 | :class => 'icon icon-add', | |
5 | :onclick => 'Element.show("add-news"); return false;' %> |
|
5 | :onclick => 'Element.show("add-news"); return false;') if @project %> | |
6 | </div> |
|
6 | </div> | |
7 |
|
7 | |||
8 | <div id="add-news" style="display:none;"> |
|
8 | <div id="add-news" style="display:none;"> | |
9 | <h2><%=l(:label_news_new)%></h2> |
|
9 | <h2><%=l(:label_news_new)%></h2> | |
10 | <% labelled_tabular_form_for :news, @news, :url => { :action => "add_news", :id => @project } do |f| %> |
|
10 | <% labelled_tabular_form_for :news, @news, :url => { :controller => 'projects', :action => "add_news", :id => @project } do |f| %> | |
11 | <%= render :partial => 'news/form', :locals => { :f => f } %> |
|
11 | <%= render :partial => 'news/form', :locals => { :f => f } %> | |
12 | <%= submit_tag l(:button_create) %> |
|
12 | <%= submit_tag l(:button_create) %> | |
13 | <%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("add-news")' %> |
|
13 | <%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("add-news")' %> | |
14 | <% end %> |
|
14 | <% end if @project %> | |
15 | </div> |
|
15 | </div> | |
16 |
|
16 | |||
17 | <h2><%=l(:label_news_plural)%></h2> |
|
17 | <h2><%=l(:label_news_plural)%></h2> | |
18 |
|
18 | |||
19 | <% if @newss.empty? %> |
|
19 | <% if @newss.empty? %> | |
20 | <p class="nodata"><%= l(:label_no_data) %></p> |
|
20 | <p class="nodata"><%= l(:label_no_data) %></p> | |
21 | <% else %> |
|
21 | <% else %> | |
22 | <% @newss.each do |news| %> |
|
22 | <% @newss.each do |news| %> | |
23 |
<h3><%= link_to |
|
23 | <h3><%= link_to(h(news.project.name), :controller => 'projects', :action => 'show', :id => news.project) + ': ' unless news.project == @project %> | |
|
24 | <%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %> | |||
24 | <%= "(#{news.comments_count} #{lwr(:label_comment, news.comments_count).downcase})" if news.comments_count > 0 %></h3> |
|
25 | <%= "(#{news.comments_count} #{lwr(:label_comment, news.comments_count).downcase})" if news.comments_count > 0 %></h3> | |
25 | <p class="author"><%= authoring news.created_on, news.author %></p> |
|
26 | <p class="author"><%= authoring news.created_on, news.author %></p> | |
26 | <%= textilizable(news.description) %> |
|
27 | <%= textilizable(news.description) %> | |
27 | <% end %> |
|
28 | <% end %> | |
28 | <% end %> |
|
29 | <% end %> | |
29 | <%= pagination_links_full @news_pages %> |
|
30 | <%= pagination_links_full @news_pages %> | |
30 |
|
31 | |||
31 | <% content_for :header_tags do %> |
|
32 | <% content_for :header_tags do %> | |
32 | <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> |
|
33 | <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> | |
33 | <% end %> |
|
34 | <% end %> |
@@ -1,83 +1,83 | |||||
1 | <h2><%=l(:label_overview)%></h2> |
|
1 | <h2><%=l(:label_overview)%></h2> | |
2 |
|
2 | |||
3 | <div class="splitcontentleft"> |
|
3 | <div class="splitcontentleft"> | |
4 | <%= textilizable @project.description %> |
|
4 | <%= textilizable @project.description %> | |
5 | <ul> |
|
5 | <ul> | |
6 | <% unless @project.homepage.blank? %><li><%=l(:field_homepage)%>: <%= auto_link @project.homepage %></li><% end %> |
|
6 | <% unless @project.homepage.blank? %><li><%=l(:field_homepage)%>: <%= auto_link @project.homepage %></li><% end %> | |
7 | <% if @subprojects.any? %> |
|
7 | <% if @subprojects.any? %> | |
8 | <li><%=l(:label_subproject_plural)%>: <%= @subprojects.collect{|p| link_to(p.name, :action => 'show', :id => p)}.join(", ") %></li> |
|
8 | <li><%=l(:label_subproject_plural)%>: <%= @subprojects.collect{|p| link_to(p.name, :action => 'show', :id => p)}.join(", ") %></li> | |
9 | <% end %> |
|
9 | <% end %> | |
10 | <% if @project.parent %> |
|
10 | <% if @project.parent %> | |
11 | <li><%=l(:field_parent)%>: <%= link_to @project.parent.name, :controller => 'projects', :action => 'show', :id => @project.parent %></li> |
|
11 | <li><%=l(:field_parent)%>: <%= link_to @project.parent.name, :controller => 'projects', :action => 'show', :id => @project.parent %></li> | |
12 | <% end %> |
|
12 | <% end %> | |
13 | <% for custom_value in @custom_values %> |
|
13 | <% for custom_value in @custom_values %> | |
14 | <% if !custom_value.value.empty? %> |
|
14 | <% if !custom_value.value.empty? %> | |
15 | <li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li> |
|
15 | <li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li> | |
16 | <% end %> |
|
16 | <% end %> | |
17 | <% end %> |
|
17 | <% end %> | |
18 | </ul> |
|
18 | </ul> | |
19 |
|
19 | |||
20 | <% if User.current.allowed_to?(:view_issues, @project) %> |
|
20 | <% if User.current.allowed_to?(:view_issues, @project) %> | |
21 | <div class="box"> |
|
21 | <div class="box"> | |
22 | <h3 class="icon22 icon22-tracker"><%=l(:label_issue_tracking)%></h3> |
|
22 | <h3 class="icon22 icon22-tracker"><%=l(:label_issue_tracking)%></h3> | |
23 | <ul> |
|
23 | <ul> | |
24 | <% for tracker in @trackers %> |
|
24 | <% for tracker in @trackers %> | |
25 | <li><%= link_to tracker.name, :controller => 'issues', :action => 'index', :project_id => @project, |
|
25 | <li><%= link_to tracker.name, :controller => 'issues', :action => 'index', :project_id => @project, | |
26 | :set_filter => 1, |
|
26 | :set_filter => 1, | |
27 | "tracker_id" => tracker.id %>: |
|
27 | "tracker_id" => tracker.id %>: | |
28 | <%= @open_issues_by_tracker[tracker] || 0 %> <%= lwr(:label_open_issues, @open_issues_by_tracker[tracker] || 0) %> |
|
28 | <%= @open_issues_by_tracker[tracker] || 0 %> <%= lwr(:label_open_issues, @open_issues_by_tracker[tracker] || 0) %> | |
29 | <%= l(:label_on) %> <%= @total_issues_by_tracker[tracker] || 0 %></li> |
|
29 | <%= l(:label_on) %> <%= @total_issues_by_tracker[tracker] || 0 %></li> | |
30 | <% end %> |
|
30 | <% end %> | |
31 | </ul> |
|
31 | </ul> | |
32 | <p><%= link_to l(:label_issue_view_all), :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1 %></p> |
|
32 | <p><%= link_to l(:label_issue_view_all), :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1 %></p> | |
33 | </div> |
|
33 | </div> | |
34 | <% end %> |
|
34 | <% end %> | |
35 | </div> |
|
35 | </div> | |
36 |
|
36 | |||
37 | <div class="splitcontentright"> |
|
37 | <div class="splitcontentright"> | |
38 | <% if @members_by_role.any? %> |
|
38 | <% if @members_by_role.any? %> | |
39 | <div class="box"> |
|
39 | <div class="box"> | |
40 | <h3 class="icon22 icon22-users"><%=l(:label_member_plural)%></h3> |
|
40 | <h3 class="icon22 icon22-users"><%=l(:label_member_plural)%></h3> | |
41 | <p><% @members_by_role.keys.sort.each do |role| %> |
|
41 | <p><% @members_by_role.keys.sort.each do |role| %> | |
42 | <%= role.name %>: |
|
42 | <%= role.name %>: | |
43 | <%= @members_by_role[role].collect(&:user).sort.collect{|u| link_to_user u}.join(", ") %> |
|
43 | <%= @members_by_role[role].collect(&:user).sort.collect{|u| link_to_user u}.join(", ") %> | |
44 | <br /> |
|
44 | <br /> | |
45 | <% end %></p> |
|
45 | <% end %></p> | |
46 | </div> |
|
46 | </div> | |
47 | <% end %> |
|
47 | <% end %> | |
48 |
|
48 | |||
49 |
<% if @news.any? && authorize_for(' |
|
49 | <% if @news.any? && authorize_for('news', 'index') %> | |
50 | <div class="box"> |
|
50 | <div class="box"> | |
51 | <h3><%=l(:label_news_latest)%></h3> |
|
51 | <h3><%=l(:label_news_latest)%></h3> | |
52 | <%= render :partial => 'news/news', :collection => @news %> |
|
52 | <%= render :partial => 'news/news', :collection => @news %> | |
53 |
<p><%= link_to l(:label_news_view_all), :controller => ' |
|
53 | <p><%= link_to l(:label_news_view_all), :controller => 'news', :action => 'index', :project_id => @project %></p> | |
54 | </div> |
|
54 | </div> | |
55 | <% end %> |
|
55 | <% end %> | |
56 | </div> |
|
56 | </div> | |
57 |
|
57 | |||
58 | <% content_for :sidebar do %> |
|
58 | <% content_for :sidebar do %> | |
59 | <% if authorize_for('projects', 'add_issue') %> |
|
59 | <% if authorize_for('projects', 'add_issue') %> | |
60 | <h3><%= l(:label_issue_new) %></h3> |
|
60 | <h3><%= l(:label_issue_new) %></h3> | |
61 | <%= l(:label_tracker) %>: <%= new_issue_selector %> |
|
61 | <%= l(:label_tracker) %>: <%= new_issue_selector %> | |
62 | <% end %> |
|
62 | <% end %> | |
63 |
|
63 | |||
64 | <% planning_links = [] |
|
64 | <% planning_links = [] | |
65 | planning_links << link_to_if_authorized(l(:label_calendar), :action => 'calendar', :id => @project) |
|
65 | planning_links << link_to_if_authorized(l(:label_calendar), :action => 'calendar', :id => @project) | |
66 | planning_links << link_to_if_authorized(l(:label_gantt), :action => 'gantt', :id => @project) |
|
66 | planning_links << link_to_if_authorized(l(:label_gantt), :action => 'gantt', :id => @project) | |
67 | planning_links.compact! |
|
67 | planning_links.compact! | |
68 | unless planning_links.empty? %> |
|
68 | unless planning_links.empty? %> | |
69 | <h3>Planning</h3> |
|
69 | <h3>Planning</h3> | |
70 | <p><%= planning_links.join(' | ') %></p> |
|
70 | <p><%= planning_links.join(' | ') %></p> | |
71 | <% end %> |
|
71 | <% end %> | |
72 |
|
72 | |||
73 | <% if @total_hours && User.current.allowed_to?(:view_time_entries, @project) %> |
|
73 | <% if @total_hours && User.current.allowed_to?(:view_time_entries, @project) %> | |
74 | <h3><%= l(:label_spent_time) %></h3> |
|
74 | <h3><%= l(:label_spent_time) %></h3> | |
75 | <p><span class="icon icon-time"><%= lwr(:label_f_hour, @total_hours) %></span></p> |
|
75 | <p><span class="icon icon-time"><%= lwr(:label_f_hour, @total_hours) %></span></p> | |
76 | <p><%= link_to(l(:label_details), {:controller => 'timelog', :action => 'details', :project_id => @project}) %> | |
|
76 | <p><%= link_to(l(:label_details), {:controller => 'timelog', :action => 'details', :project_id => @project}) %> | | |
77 | <%= link_to(l(:label_report), {:controller => 'timelog', :action => 'report', :project_id => @project}) %></p> |
|
77 | <%= link_to(l(:label_report), {:controller => 'timelog', :action => 'report', :project_id => @project}) %></p> | |
78 | <% end %> |
|
78 | <% end %> | |
79 | <% end %> |
|
79 | <% end %> | |
80 |
|
80 | |||
81 | <% content_for :header_tags do %> |
|
81 | <% content_for :header_tags do %> | |
82 | <%= auto_discovery_link_tag(:atom, {:action => 'activity', :id => @project, :format => 'atom', :key => User.current.rss_key}) %> |
|
82 | <%= auto_discovery_link_tag(:atom, {:action => 'activity', :id => @project, :format => 'atom', :key => User.current.rss_key}) %> | |
83 | <% end %> |
|
83 | <% end %> |
@@ -1,28 +1,31 | |||||
1 | <h2><%= l(:label_home) %></h2> |
|
1 | <h2><%= l(:label_home) %></h2> | |
2 |
|
2 | |||
3 | <div class="splitcontentleft"> |
|
3 | <div class="splitcontentleft"> | |
4 | <%= textilizable Setting.welcome_text %> |
|
4 | <%= textilizable Setting.welcome_text %> | |
|
5 | <% if @news.any? %> | |||
5 | <div class="box"> |
|
6 | <div class="box"> | |
6 | <h3><%=l(:label_news_latest)%></h3> |
|
7 | <h3><%=l(:label_news_latest)%></h3> | |
7 | <%= render :partial => 'news/news', :collection => @news %> |
|
8 | <%= render :partial => 'news/news', :collection => @news %> | |
|
9 | <%= link_to l(:label_issue_view_all), :controller => 'news' %> | |||
8 |
|
|
10 | </div> | |
|
11 | <% end %> | |||
9 | </div> |
|
12 | </div> | |
10 |
|
13 | |||
11 | <div class="splitcontentright"> |
|
14 | <div class="splitcontentright"> | |
12 | <div class="box"> |
|
15 | <div class="box"> | |
13 | <h3 class="icon22 icon22-projects"><%=l(:label_project_latest)%></h3> |
|
16 | <h3 class="icon22 icon22-projects"><%=l(:label_project_latest)%></h3> | |
14 | <ul> |
|
17 | <ul> | |
15 | <% for project in @projects %> |
|
18 | <% for project in @projects %> | |
16 | <li> |
|
19 | <li> | |
17 | <%= link_to project.name, :controller => 'projects', :action => 'show', :id => project %> (<%= format_time(project.created_on) %>) |
|
20 | <%= link_to project.name, :controller => 'projects', :action => 'show', :id => project %> (<%= format_time(project.created_on) %>) | |
18 | <%= textilizable project.description, :project => project %> |
|
21 | <%= textilizable project.description, :project => project %> | |
19 | </li> |
|
22 | </li> | |
20 | <% end %> |
|
23 | <% end %> | |
21 | </ul> |
|
24 | </ul> | |
22 | </div> |
|
25 | </div> | |
23 | </div> |
|
26 | </div> | |
24 |
|
27 | |||
25 | <% content_for :header_tags do %> |
|
28 | <% content_for :header_tags do %> | |
26 | <%= auto_discovery_link_tag(:rss, {:controller => 'feeds', :action => 'news', :key => @key}, {:title => l(:label_news_latest)}) %> |
|
29 | <%= auto_discovery_link_tag(:rss, {:controller => 'feeds', :action => 'news', :key => @key}, {:title => l(:label_news_latest)}) %> | |
27 | <%= auto_discovery_link_tag(:atom, {:controller => 'feeds', :action => 'news', :key => @key, :format => 'atom'}, {:title => l(:label_news_latest)}) %> |
|
30 | <%= auto_discovery_link_tag(:atom, {:controller => 'feeds', :action => 'news', :key => @key, :format => 'atom'}, {:title => l(:label_news_latest)}) %> | |
28 | <% end %> |
|
31 | <% end %> |
@@ -1,35 +1,36 | |||||
1 | ActionController::Routing::Routes.draw do |map| |
|
1 | ActionController::Routing::Routes.draw do |map| | |
2 | # Add your own custom routes here. |
|
2 | # Add your own custom routes here. | |
3 | # The priority is based upon order of creation: first created -> highest priority. |
|
3 | # The priority is based upon order of creation: first created -> highest priority. | |
4 |
|
4 | |||
5 | # Here's a sample route: |
|
5 | # Here's a sample route: | |
6 | # map.connect 'products/:id', :controller => 'catalog', :action => 'view' |
|
6 | # map.connect 'products/:id', :controller => 'catalog', :action => 'view' | |
7 | # Keep in mind you can assign values other than :controller and :action |
|
7 | # Keep in mind you can assign values other than :controller and :action | |
8 |
|
8 | |||
9 | map.home '', :controller => 'welcome' |
|
9 | map.home '', :controller => 'welcome' | |
10 |
|
10 | |||
11 | map.connect 'wiki/:id/:page/:action', :controller => 'wiki', :page => nil |
|
11 | map.connect 'wiki/:id/:page/:action', :controller => 'wiki', :page => nil | |
12 | map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow' |
|
12 | map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow' | |
13 | map.connect 'help/:ctrl/:page', :controller => 'help' |
|
13 | map.connect 'help/:ctrl/:page', :controller => 'help' | |
14 | #map.connect ':controller/:action/:id/:sort_key/:sort_order' |
|
14 | #map.connect ':controller/:action/:id/:sort_key/:sort_order' | |
15 |
|
15 | |||
16 | map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations' |
|
16 | map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations' | |
17 | map.connect 'projects/:project_id/issues/:action', :controller => 'issues' |
|
17 | map.connect 'projects/:project_id/issues/:action', :controller => 'issues' | |
|
18 | map.connect 'projects/:project_id/news/:action', :controller => 'news' | |||
18 | map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards' |
|
19 | map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards' | |
19 | map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages' |
|
20 | map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages' | |
20 |
|
21 | |||
21 | map.with_options :controller => 'repositories' do |omap| |
|
22 | map.with_options :controller => 'repositories' do |omap| | |
22 | omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse' |
|
23 | omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse' | |
23 | omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes' |
|
24 | omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes' | |
24 | omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff' |
|
25 | omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff' | |
25 | omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry' |
|
26 | omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry' | |
26 | end |
|
27 | end | |
27 |
|
28 | |||
28 | # Allow downloading Web Service WSDL as a file with an extension |
|
29 | # Allow downloading Web Service WSDL as a file with an extension | |
29 | # instead of a file named 'wsdl' |
|
30 | # instead of a file named 'wsdl' | |
30 | map.connect ':controller/service.wsdl', :action => 'wsdl' |
|
31 | map.connect ':controller/service.wsdl', :action => 'wsdl' | |
31 |
|
32 | |||
32 |
|
33 | |||
33 | # Install the default route as the lowest priority. |
|
34 | # Install the default route as the lowest priority. | |
34 | map.connect ':controller/:action/:id' |
|
35 | map.connect ':controller/:action/:id' | |
35 | end |
|
36 | end |
@@ -1,103 +1,103 | |||||
1 | require 'redmine/access_control' |
|
1 | require 'redmine/access_control' | |
2 | require 'redmine/menu_manager' |
|
2 | require 'redmine/menu_manager' | |
3 | require 'redmine/mime_type' |
|
3 | require 'redmine/mime_type' | |
4 | require 'redmine/themes' |
|
4 | require 'redmine/themes' | |
5 | require 'redmine/plugin' |
|
5 | require 'redmine/plugin' | |
6 |
|
6 | |||
7 | begin |
|
7 | begin | |
8 | require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick) |
|
8 | require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick) | |
9 | rescue LoadError |
|
9 | rescue LoadError | |
10 | # RMagick is not available |
|
10 | # RMagick is not available | |
11 | end |
|
11 | end | |
12 |
|
12 | |||
13 | REDMINE_SUPPORTED_SCM = %w( Subversion Darcs Mercurial Cvs ) |
|
13 | REDMINE_SUPPORTED_SCM = %w( Subversion Darcs Mercurial Cvs ) | |
14 |
|
14 | |||
15 | # Permissions |
|
15 | # Permissions | |
16 | Redmine::AccessControl.map do |map| |
|
16 | Redmine::AccessControl.map do |map| | |
17 | map.permission :view_project, {:projects => [:show, :activity]}, :public => true |
|
17 | map.permission :view_project, {:projects => [:show, :activity]}, :public => true | |
18 | map.permission :search_project, {:search => :index}, :public => true |
|
18 | map.permission :search_project, {:search => :index}, :public => true | |
19 | map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member |
|
19 | map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member | |
20 | map.permission :select_project_modules, {:projects => :modules}, :require => :member |
|
20 | map.permission :select_project_modules, {:projects => :modules}, :require => :member | |
21 | map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy]}, :require => :member |
|
21 | map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy]}, :require => :member | |
22 | map.permission :manage_versions, {:projects => [:settings, :add_version], :versions => [:edit, :destroy]}, :require => :member |
|
22 | map.permission :manage_versions, {:projects => [:settings, :add_version], :versions => [:edit, :destroy]}, :require => :member | |
23 |
|
23 | |||
24 | map.project_module :issue_tracking do |map| |
|
24 | map.project_module :issue_tracking do |map| | |
25 | # Issue categories |
|
25 | # Issue categories | |
26 | map.permission :manage_categories, {:projects => [:settings, :add_issue_category], :issue_categories => [:edit, :destroy]}, :require => :member |
|
26 | map.permission :manage_categories, {:projects => [:settings, :add_issue_category], :issue_categories => [:edit, :destroy]}, :require => :member | |
27 | # Issues |
|
27 | # Issues | |
28 | map.permission :view_issues, {:projects => [:changelog, :roadmap], |
|
28 | map.permission :view_issues, {:projects => [:changelog, :roadmap], | |
29 | :issues => [:index, :changes, :show, :context_menu], |
|
29 | :issues => [:index, :changes, :show, :context_menu], | |
30 | :queries => :index, |
|
30 | :queries => :index, | |
31 | :reports => :issue_report}, :public => true |
|
31 | :reports => :issue_report}, :public => true | |
32 | map.permission :add_issues, {:projects => :add_issue}, :require => :loggedin |
|
32 | map.permission :add_issues, {:projects => :add_issue}, :require => :loggedin | |
33 | map.permission :edit_issues, {:projects => :bulk_edit_issues, |
|
33 | map.permission :edit_issues, {:projects => :bulk_edit_issues, | |
34 | :issues => [:edit, :destroy_attachment]}, :require => :loggedin |
|
34 | :issues => [:edit, :destroy_attachment]}, :require => :loggedin | |
35 | map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}, :require => :loggedin |
|
35 | map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}, :require => :loggedin | |
36 | map.permission :add_issue_notes, {:issues => :add_note}, :require => :loggedin |
|
36 | map.permission :add_issue_notes, {:issues => :add_note}, :require => :loggedin | |
37 | map.permission :change_issue_status, {:issues => :change_status}, :require => :loggedin |
|
37 | map.permission :change_issue_status, {:issues => :change_status}, :require => :loggedin | |
38 | map.permission :move_issues, {:projects => :move_issues}, :require => :loggedin |
|
38 | map.permission :move_issues, {:projects => :move_issues}, :require => :loggedin | |
39 | map.permission :delete_issues, {:issues => :destroy}, :require => :member |
|
39 | map.permission :delete_issues, {:issues => :destroy}, :require => :member | |
40 | # Queries |
|
40 | # Queries | |
41 | map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member |
|
41 | map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member | |
42 | map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin |
|
42 | map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin | |
43 | # Gantt & calendar |
|
43 | # Gantt & calendar | |
44 | map.permission :view_gantt, :projects => :gantt |
|
44 | map.permission :view_gantt, :projects => :gantt | |
45 | map.permission :view_calendar, :projects => :calendar |
|
45 | map.permission :view_calendar, :projects => :calendar | |
46 | end |
|
46 | end | |
47 |
|
47 | |||
48 | map.project_module :time_tracking do |map| |
|
48 | map.project_module :time_tracking do |map| | |
49 | map.permission :log_time, {:timelog => :edit}, :require => :loggedin |
|
49 | map.permission :log_time, {:timelog => :edit}, :require => :loggedin | |
50 | map.permission :view_time_entries, :timelog => [:details, :report] |
|
50 | map.permission :view_time_entries, :timelog => [:details, :report] | |
51 | end |
|
51 | end | |
52 |
|
52 | |||
53 | map.project_module :news do |map| |
|
53 | map.project_module :news do |map| | |
54 | map.permission :manage_news, {:projects => :add_news, :news => [:edit, :destroy, :destroy_comment]}, :require => :member |
|
54 | map.permission :manage_news, {:projects => :add_news, :news => [:edit, :destroy, :destroy_comment]}, :require => :member | |
55 |
map.permission :view_news, { |
|
55 | map.permission :view_news, {:news => [:index, :show]}, :public => true | |
56 | map.permission :comment_news, {:news => :add_comment}, :require => :loggedin |
|
56 | map.permission :comment_news, {:news => :add_comment}, :require => :loggedin | |
57 | end |
|
57 | end | |
58 |
|
58 | |||
59 | map.project_module :documents do |map| |
|
59 | map.project_module :documents do |map| | |
60 | map.permission :manage_documents, {:projects => :add_document, :documents => [:edit, :destroy, :add_attachment, :destroy_attachment]}, :require => :loggedin |
|
60 | map.permission :manage_documents, {:projects => :add_document, :documents => [:edit, :destroy, :add_attachment, :destroy_attachment]}, :require => :loggedin | |
61 | map.permission :view_documents, :projects => :list_documents, :documents => [:show, :download] |
|
61 | map.permission :view_documents, :projects => :list_documents, :documents => [:show, :download] | |
62 | end |
|
62 | end | |
63 |
|
63 | |||
64 | map.project_module :files do |map| |
|
64 | map.project_module :files do |map| | |
65 | map.permission :manage_files, {:projects => :add_file, :versions => :destroy_file}, :require => :loggedin |
|
65 | map.permission :manage_files, {:projects => :add_file, :versions => :destroy_file}, :require => :loggedin | |
66 | map.permission :view_files, :projects => :list_files, :versions => :download |
|
66 | map.permission :view_files, :projects => :list_files, :versions => :download | |
67 | end |
|
67 | end | |
68 |
|
68 | |||
69 | map.project_module :wiki do |map| |
|
69 | map.project_module :wiki do |map| | |
70 | map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member |
|
70 | map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member | |
71 | map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member |
|
71 | map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member | |
72 | map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member |
|
72 | map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member | |
73 | map.permission :view_wiki_pages, :wiki => [:index, :history, :diff, :special] |
|
73 | map.permission :view_wiki_pages, :wiki => [:index, :history, :diff, :special] | |
74 | map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment, :destroy_attachment] |
|
74 | map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment, :destroy_attachment] | |
75 | end |
|
75 | end | |
76 |
|
76 | |||
77 | map.project_module :repository do |map| |
|
77 | map.project_module :repository do |map| | |
78 | map.permission :manage_repository, {:repositories => [:edit, :destroy]}, :require => :member |
|
78 | map.permission :manage_repository, {:repositories => [:edit, :destroy]}, :require => :member | |
79 | map.permission :browse_repository, :repositories => [:show, :browse, :entry, :changes, :diff, :stats, :graph] |
|
79 | map.permission :browse_repository, :repositories => [:show, :browse, :entry, :changes, :diff, :stats, :graph] | |
80 | map.permission :view_changesets, :repositories => [:show, :revisions, :revision] |
|
80 | map.permission :view_changesets, :repositories => [:show, :revisions, :revision] | |
81 | end |
|
81 | end | |
82 |
|
82 | |||
83 | map.project_module :boards do |map| |
|
83 | map.project_module :boards do |map| | |
84 | map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member |
|
84 | map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member | |
85 | map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true |
|
85 | map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true | |
86 | map.permission :add_messages, {:messages => [:new, :reply]}, :require => :loggedin |
|
86 | map.permission :add_messages, {:messages => [:new, :reply]}, :require => :loggedin | |
87 | end |
|
87 | end | |
88 | end |
|
88 | end | |
89 |
|
89 | |||
90 | # Project menu configuration |
|
90 | # Project menu configuration | |
91 | Redmine::MenuManager.map :project_menu do |menu| |
|
91 | Redmine::MenuManager.map :project_menu do |menu| | |
92 | menu.push :label_overview, :controller => 'projects', :action => 'show' |
|
92 | menu.push :label_overview, :controller => 'projects', :action => 'show' | |
93 | menu.push :label_activity, :controller => 'projects', :action => 'activity' |
|
93 | menu.push :label_activity, :controller => 'projects', :action => 'activity' | |
94 | menu.push :label_roadmap, :controller => 'projects', :action => 'roadmap' |
|
94 | menu.push :label_roadmap, :controller => 'projects', :action => 'roadmap' | |
95 | menu.push :label_issue_plural, { :controller => 'issues', :action => 'index' }, :param => :project_id |
|
95 | menu.push :label_issue_plural, { :controller => 'issues', :action => 'index' }, :param => :project_id | |
96 |
menu.push :label_news_plural, :controller => ' |
|
96 | menu.push :label_news_plural, { :controller => 'news', :action => 'index' }, :param => :project_id | |
97 | menu.push :label_document_plural, :controller => 'projects', :action => 'list_documents' |
|
97 | menu.push :label_document_plural, :controller => 'projects', :action => 'list_documents' | |
98 | menu.push :label_wiki, { :controller => 'wiki', :action => 'index', :page => nil }, :if => Proc.new { |p| p.wiki && !p.wiki.new_record? } |
|
98 | menu.push :label_wiki, { :controller => 'wiki', :action => 'index', :page => nil }, :if => Proc.new { |p| p.wiki && !p.wiki.new_record? } | |
99 | menu.push :label_board_plural, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, :if => Proc.new { |p| p.boards.any? } |
|
99 | menu.push :label_board_plural, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, :if => Proc.new { |p| p.boards.any? } | |
100 | menu.push :label_attachment_plural, :controller => 'projects', :action => 'list_files' |
|
100 | menu.push :label_attachment_plural, :controller => 'projects', :action => 'list_files' | |
101 | menu.push :label_repository, { :controller => 'repositories', :action => 'show' }, :if => Proc.new { |p| p.repository && !p.repository.new_record? } |
|
101 | menu.push :label_repository, { :controller => 'repositories', :action => 'show' }, :if => Proc.new { |p| p.repository && !p.repository.new_record? } | |
102 | menu.push :label_settings, :controller => 'projects', :action => 'settings' |
|
102 | menu.push :label_settings, :controller => 'projects', :action => 'settings' | |
103 | end |
|
103 | end |
@@ -1,66 +1,48 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
19 |
require ' |
|
19 | require 'news_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 |
class |
|
22 | class NewsController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 |
class |
|
24 | class NewsControllerTest < Test::Unit::TestCase | |
25 |
fixtures :projects, :users, :members, : |
|
25 | fixtures :projects, :users, :roles, :members, :enabled_modules | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 |
@controller = |
|
28 | @controller = NewsController.new | |
29 | @request = ActionController::TestRequest.new |
|
29 | @request = ActionController::TestRequest.new | |
30 | @response = ActionController::TestResponse.new |
|
30 | @response = ActionController::TestResponse.new | |
|
31 | User.current = nil | |||
31 | end |
|
32 | end | |
32 |
|
33 | |||
33 |
def test_ |
|
34 | def test_index | |
34 |
get : |
|
35 | get :index | |
35 | assert_response :success |
|
36 | assert_response :success | |
36 |
assert_template ' |
|
37 | assert_template 'index' | |
37 | assert_not_nil assigns(:news) |
|
38 | assert_not_nil assigns(:newss) | |
|
39 | assert_nil assigns(:project) | |||
38 | end |
|
40 | end | |
39 |
|
41 | |||
40 | def test_issues |
|
42 | def test_index_with_project | |
41 | get :issues |
|
43 | get :index, :project_id => 1 | |
42 | assert_response :success |
|
|||
43 | assert_template 'issues' |
|
|||
44 | assert_not_nil assigns(:issues) |
|
|||
45 | end |
|
|||
46 |
|
||||
47 | def test_history |
|
|||
48 | get :history |
|
|||
49 | assert_response :success |
|
|||
50 | assert_template 'history' |
|
|||
51 | assert_not_nil assigns(:journals) |
|
|||
52 | end |
|
|||
53 |
|
||||
54 | def test_project_privacy |
|
|||
55 | get :news, :project_id => 2 |
|
|||
56 | assert_response 403 |
|
|||
57 | end |
|
|||
58 |
|
||||
59 | def test_rss_key |
|
|||
60 | user = User.find(2) |
|
|||
61 | key = user.rss_key |
|
|||
62 |
|
||||
63 | get :news, :project_id => 2, :key => key |
|
|||
64 | assert_response :success |
|
44 | assert_response :success | |
|
45 | assert_template 'index' | |||
|
46 | assert_not_nil assigns(:newss) | |||
65 | end |
|
47 | end | |
66 | end |
|
48 | end |
@@ -1,138 +1,131 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
19 | require 'projects_controller' |
|
19 | require 'projects_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class ProjectsController; def rescue_action(e) raise e end; end |
|
22 | class ProjectsController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class ProjectsControllerTest < Test::Unit::TestCase |
|
24 | class ProjectsControllerTest < Test::Unit::TestCase | |
25 | fixtures :projects, :users, :roles, :members, :issues, :enabled_modules, :enumerations |
|
25 | fixtures :projects, :users, :roles, :members, :issues, :enabled_modules, :enumerations | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 | @controller = ProjectsController.new |
|
28 | @controller = ProjectsController.new | |
29 | @request = ActionController::TestRequest.new |
|
29 | @request = ActionController::TestRequest.new | |
30 | @response = ActionController::TestResponse.new |
|
30 | @response = ActionController::TestResponse.new | |
31 | end |
|
31 | end | |
32 |
|
32 | |||
33 | def test_index |
|
33 | def test_index | |
34 | get :index |
|
34 | get :index | |
35 | assert_response :success |
|
35 | assert_response :success | |
36 | assert_template 'list' |
|
36 | assert_template 'list' | |
37 | end |
|
37 | end | |
38 |
|
38 | |||
39 | def test_list |
|
39 | def test_list | |
40 | get :list |
|
40 | get :list | |
41 | assert_response :success |
|
41 | assert_response :success | |
42 | assert_template 'list' |
|
42 | assert_template 'list' | |
43 | assert_not_nil assigns(:project_tree) |
|
43 | assert_not_nil assigns(:project_tree) | |
44 | end |
|
44 | end | |
45 |
|
45 | |||
46 | def test_show |
|
46 | def test_show | |
47 | get :show, :id => 1 |
|
47 | get :show, :id => 1 | |
48 | assert_response :success |
|
48 | assert_response :success | |
49 | assert_template 'show' |
|
49 | assert_template 'show' | |
50 | assert_not_nil assigns(:project) |
|
50 | assert_not_nil assigns(:project) | |
51 | end |
|
51 | end | |
52 |
|
52 | |||
53 | def test_list_documents |
|
53 | def test_list_documents | |
54 | get :list_documents, :id => 1 |
|
54 | get :list_documents, :id => 1 | |
55 | assert_response :success |
|
55 | assert_response :success | |
56 | assert_template 'list_documents' |
|
56 | assert_template 'list_documents' | |
57 | assert_not_nil assigns(:grouped) |
|
57 | assert_not_nil assigns(:grouped) | |
58 | end |
|
58 | end | |
59 |
|
59 | |||
60 | def test_bulk_edit_issues |
|
60 | def test_bulk_edit_issues | |
61 | @request.session[:user_id] = 2 |
|
61 | @request.session[:user_id] = 2 | |
62 | # update issues priority |
|
62 | # update issues priority | |
63 | post :bulk_edit_issues, :id => 1, :issue_ids => [1, 2], :priority_id => 7, :notes => 'Bulk editing', :assigned_to_id => '' |
|
63 | post :bulk_edit_issues, :id => 1, :issue_ids => [1, 2], :priority_id => 7, :notes => 'Bulk editing', :assigned_to_id => '' | |
64 | assert_response 302 |
|
64 | assert_response 302 | |
65 | # check that the issues were updated |
|
65 | # check that the issues were updated | |
66 | assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id} |
|
66 | assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id} | |
67 | assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes |
|
67 | assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes | |
68 | end |
|
68 | end | |
69 |
|
69 | |||
70 | def test_list_news |
|
|||
71 | get :list_news, :id => 1 |
|
|||
72 | assert_response :success |
|
|||
73 | assert_template 'list_news' |
|
|||
74 | assert_not_nil assigns(:newss) |
|
|||
75 | end |
|
|||
76 |
|
||||
77 | def test_list_files |
|
70 | def test_list_files | |
78 | get :list_files, :id => 1 |
|
71 | get :list_files, :id => 1 | |
79 | assert_response :success |
|
72 | assert_response :success | |
80 | assert_template 'list_files' |
|
73 | assert_template 'list_files' | |
81 | assert_not_nil assigns(:versions) |
|
74 | assert_not_nil assigns(:versions) | |
82 | end |
|
75 | end | |
83 |
|
76 | |||
84 | def test_changelog |
|
77 | def test_changelog | |
85 | get :changelog, :id => 1 |
|
78 | get :changelog, :id => 1 | |
86 | assert_response :success |
|
79 | assert_response :success | |
87 | assert_template 'changelog' |
|
80 | assert_template 'changelog' | |
88 | assert_not_nil assigns(:versions) |
|
81 | assert_not_nil assigns(:versions) | |
89 | end |
|
82 | end | |
90 |
|
83 | |||
91 | def test_roadmap |
|
84 | def test_roadmap | |
92 | get :roadmap, :id => 1 |
|
85 | get :roadmap, :id => 1 | |
93 | assert_response :success |
|
86 | assert_response :success | |
94 | assert_template 'roadmap' |
|
87 | assert_template 'roadmap' | |
95 | assert_not_nil assigns(:versions) |
|
88 | assert_not_nil assigns(:versions) | |
96 | end |
|
89 | end | |
97 |
|
90 | |||
98 | def test_activity |
|
91 | def test_activity | |
99 | get :activity, :id => 1 |
|
92 | get :activity, :id => 1 | |
100 | assert_response :success |
|
93 | assert_response :success | |
101 | assert_template 'activity' |
|
94 | assert_template 'activity' | |
102 | assert_not_nil assigns(:events_by_day) |
|
95 | assert_not_nil assigns(:events_by_day) | |
103 | end |
|
96 | end | |
104 |
|
97 | |||
105 | def test_archive |
|
98 | def test_archive | |
106 | @request.session[:user_id] = 1 # admin |
|
99 | @request.session[:user_id] = 1 # admin | |
107 | post :archive, :id => 1 |
|
100 | post :archive, :id => 1 | |
108 | assert_redirected_to 'admin/projects' |
|
101 | assert_redirected_to 'admin/projects' | |
109 | assert !Project.find(1).active? |
|
102 | assert !Project.find(1).active? | |
110 | end |
|
103 | end | |
111 |
|
104 | |||
112 | def test_unarchive |
|
105 | def test_unarchive | |
113 | @request.session[:user_id] = 1 # admin |
|
106 | @request.session[:user_id] = 1 # admin | |
114 | Project.find(1).archive |
|
107 | Project.find(1).archive | |
115 | post :unarchive, :id => 1 |
|
108 | post :unarchive, :id => 1 | |
116 | assert_redirected_to 'admin/projects' |
|
109 | assert_redirected_to 'admin/projects' | |
117 | assert Project.find(1).active? |
|
110 | assert Project.find(1).active? | |
118 | end |
|
111 | end | |
119 |
|
112 | |||
120 | def test_add_issue |
|
113 | def test_add_issue | |
121 | @request.session[:user_id] = 2 |
|
114 | @request.session[:user_id] = 2 | |
122 | get :add_issue, :id => 1, :tracker_id => 1 |
|
115 | get :add_issue, :id => 1, :tracker_id => 1 | |
123 | assert_response :success |
|
116 | assert_response :success | |
124 | assert_template 'add_issue' |
|
117 | assert_template 'add_issue' | |
125 | post :add_issue, :id => 1, :issue => {:tracker_id => 1, :subject => 'This is the test_add_issue issue', :description => 'This is the description', :priority_id => 5} |
|
118 | post :add_issue, :id => 1, :issue => {:tracker_id => 1, :subject => 'This is the test_add_issue issue', :description => 'This is the description', :priority_id => 5} | |
126 | assert_redirected_to 'projects/1/issues' |
|
119 | assert_redirected_to 'projects/1/issues' | |
127 | assert Issue.find_by_subject('This is the test_add_issue issue') |
|
120 | assert Issue.find_by_subject('This is the test_add_issue issue') | |
128 | end |
|
121 | end | |
129 |
|
122 | |||
130 | def test_copy_issue |
|
123 | def test_copy_issue | |
131 | @request.session[:user_id] = 2 |
|
124 | @request.session[:user_id] = 2 | |
132 | get :add_issue, :id => 1, :copy_from => 1 |
|
125 | get :add_issue, :id => 1, :copy_from => 1 | |
133 | assert_template 'add_issue' |
|
126 | assert_template 'add_issue' | |
134 | assert_not_nil assigns(:issue) |
|
127 | assert_not_nil assigns(:issue) | |
135 | orig = Issue.find(1) |
|
128 | orig = Issue.find(1) | |
136 | assert_equal orig.subject, assigns(:issue).subject |
|
129 | assert_equal orig.subject, assigns(:issue).subject | |
137 | end |
|
130 | end | |
138 | end |
|
131 | end |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now