|
@@
-1,531
+1,532
|
|
1
|
# redMine - project management software
|
|
1
|
# redMine - project management software
|
|
2
|
# Copyright (C) 2006 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, :authorize, :except => [ :index, :list, :add ]
|
|
20
|
before_filter :find_project, :authorize, :except => [ :index, :list, :add ]
|
|
21
|
before_filter :require_admin, :only => [ :add, :destroy ]
|
|
21
|
before_filter :require_admin, :only => [ :add, :destroy ]
|
|
22
|
|
|
22
|
|
|
23
|
helper :sort
|
|
23
|
helper :sort
|
|
24
|
include SortHelper
|
|
24
|
include SortHelper
|
|
25
|
helper :custom_fields
|
|
25
|
helper :custom_fields
|
|
26
|
include CustomFieldsHelper
|
|
26
|
include CustomFieldsHelper
|
|
27
|
helper :ifpdf
|
|
27
|
helper :ifpdf
|
|
28
|
include IfpdfHelper
|
|
28
|
include IfpdfHelper
|
|
29
|
helper IssuesHelper
|
|
29
|
helper IssuesHelper
|
|
30
|
helper :queries
|
|
30
|
helper :queries
|
|
31
|
include QueriesHelper
|
|
31
|
include QueriesHelper
|
|
32
|
|
|
32
|
|
|
33
|
def index
|
|
33
|
def index
|
|
34
|
list
|
|
34
|
list
|
|
35
|
render :action => 'list' unless request.xhr?
|
|
35
|
render :action => 'list' unless request.xhr?
|
|
36
|
end
|
|
36
|
end
|
|
37
|
|
|
37
|
|
|
38
|
# Lists public projects
|
|
38
|
# Lists public projects
|
|
39
|
def list
|
|
39
|
def list
|
|
40
|
sort_init 'name', 'asc'
|
|
40
|
sort_init 'name', 'asc'
|
|
41
|
sort_update
|
|
41
|
sort_update
|
|
42
|
@project_count = Project.count(["is_public=?", true])
|
|
42
|
@project_count = Project.count(["is_public=?", true])
|
|
43
|
@project_pages = Paginator.new self, @project_count,
|
|
43
|
@project_pages = Paginator.new self, @project_count,
|
|
44
|
15,
|
|
44
|
15,
|
|
45
|
params['page']
|
|
45
|
params['page']
|
|
46
|
@projects = Project.find :all, :order => sort_clause,
|
|
46
|
@projects = Project.find :all, :order => sort_clause,
|
|
47
|
:conditions => ["is_public=?", true],
|
|
47
|
:conditions => ["is_public=?", true],
|
|
48
|
:limit => @project_pages.items_per_page,
|
|
48
|
:limit => @project_pages.items_per_page,
|
|
49
|
:offset => @project_pages.current.offset
|
|
49
|
:offset => @project_pages.current.offset
|
|
50
|
|
|
50
|
|
|
51
|
render :action => "list", :layout => false if request.xhr?
|
|
51
|
render :action => "list", :layout => false if request.xhr?
|
|
52
|
end
|
|
52
|
end
|
|
53
|
|
|
53
|
|
|
54
|
# Add a new project
|
|
54
|
# Add a new project
|
|
55
|
def add
|
|
55
|
def add
|
|
56
|
@custom_fields = IssueCustomField.find(:all)
|
|
56
|
@custom_fields = IssueCustomField.find(:all)
|
|
57
|
@root_projects = Project.find(:all, :conditions => "parent_id is null")
|
|
57
|
@root_projects = Project.find(:all, :conditions => "parent_id is null")
|
|
58
|
@project = Project.new(params[:project])
|
|
58
|
@project = Project.new(params[:project])
|
|
59
|
if request.get?
|
|
59
|
if request.get?
|
|
60
|
@custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
|
|
60
|
@custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
|
|
61
|
else
|
|
61
|
else
|
|
62
|
@project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
|
|
62
|
@project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
|
|
63
|
@custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
|
|
63
|
@custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
|
|
64
|
@project.custom_values = @custom_values
|
|
64
|
@project.custom_values = @custom_values
|
|
65
|
if params[:repository_enabled] && params[:repository_enabled] == "1"
|
|
65
|
if params[:repository_enabled] && params[:repository_enabled] == "1"
|
|
66
|
@project.repository = Repository.new
|
|
66
|
@project.repository = Repository.new
|
|
67
|
@project.repository.attributes = params[:repository]
|
|
67
|
@project.repository.attributes = params[:repository]
|
|
68
|
end
|
|
68
|
end
|
|
69
|
if @project.save
|
|
69
|
if @project.save
|
|
70
|
flash[:notice] = l(:notice_successful_create)
|
|
70
|
flash[:notice] = l(:notice_successful_create)
|
|
71
|
redirect_to :controller => 'admin', :action => 'projects'
|
|
71
|
redirect_to :controller => 'admin', :action => 'projects'
|
|
72
|
end
|
|
72
|
end
|
|
73
|
end
|
|
73
|
end
|
|
74
|
end
|
|
74
|
end
|
|
75
|
|
|
75
|
|
|
76
|
# Show @project
|
|
76
|
# Show @project
|
|
77
|
def show
|
|
77
|
def show
|
|
78
|
@custom_values = @project.custom_values.find(:all, :include => :custom_field)
|
|
78
|
@custom_values = @project.custom_values.find(:all, :include => :custom_field)
|
|
79
|
@members = @project.members.find(:all, :include => [:user, :role])
|
|
79
|
@members = @project.members.find(:all, :include => [:user, :role])
|
|
80
|
@subprojects = @project.children if @project.children_count > 0
|
|
80
|
@subprojects = @project.children if @project.children_count > 0
|
|
81
|
@news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC")
|
|
81
|
@news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC")
|
|
82
|
@trackers = Tracker.find(:all)
|
|
82
|
@trackers = Tracker.find(:all)
|
|
83
|
end
|
|
83
|
end
|
|
84
|
|
|
84
|
|
|
85
|
def settings
|
|
85
|
def settings
|
|
86
|
@root_projects = Project::find(:all, :conditions => ["parent_id is null and id <> ?", @project.id])
|
|
86
|
@root_projects = Project::find(:all, :conditions => ["parent_id is null and id <> ?", @project.id])
|
|
87
|
@custom_fields = IssueCustomField.find(:all)
|
|
87
|
@custom_fields = IssueCustomField.find(:all)
|
|
88
|
@issue_category ||= IssueCategory.new
|
|
88
|
@issue_category ||= IssueCategory.new
|
|
89
|
@member ||= @project.members.new
|
|
89
|
@member ||= @project.members.new
|
|
90
|
@roles = Role.find(:all)
|
|
90
|
@roles = Role.find(:all)
|
|
91
|
@users = User.find(:all) - @project.members.find(:all, :include => :user).collect{|m| m.user }
|
|
91
|
@users = User.find(:all) - @project.members.find(:all, :include => :user).collect{|m| m.user }
|
|
92
|
@custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
|
|
92
|
@custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
|
|
93
|
end
|
|
93
|
end
|
|
94
|
|
|
94
|
|
|
95
|
# Edit @project
|
|
95
|
# Edit @project
|
|
96
|
def edit
|
|
96
|
def edit
|
|
97
|
if request.post?
|
|
97
|
if request.post?
|
|
98
|
@project.custom_fields = IssueCustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
|
|
98
|
@project.custom_fields = IssueCustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
|
|
99
|
if params[:custom_fields]
|
|
99
|
if params[:custom_fields]
|
|
100
|
@custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
|
|
100
|
@custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
|
|
101
|
@project.custom_values = @custom_values
|
|
101
|
@project.custom_values = @custom_values
|
|
102
|
end
|
|
102
|
end
|
|
103
|
if params[:repository_enabled]
|
|
103
|
if params[:repository_enabled]
|
|
104
|
case params[:repository_enabled]
|
|
104
|
case params[:repository_enabled]
|
|
105
|
when "0"
|
|
105
|
when "0"
|
|
106
|
@project.repository = nil
|
|
106
|
@project.repository = nil
|
|
107
|
when "1"
|
|
107
|
when "1"
|
|
108
|
@project.repository ||= Repository.new
|
|
108
|
@project.repository ||= Repository.new
|
|
109
|
@project.repository.attributes = params[:repository]
|
|
109
|
@project.repository.attributes = params[:repository]
|
|
110
|
end
|
|
110
|
end
|
|
111
|
end
|
|
111
|
end
|
|
112
|
@project.attributes = params[:project]
|
|
112
|
@project.attributes = params[:project]
|
|
113
|
if @project.save
|
|
113
|
if @project.save
|
|
114
|
flash[:notice] = l(:notice_successful_update)
|
|
114
|
flash[:notice] = l(:notice_successful_update)
|
|
115
|
redirect_to :action => 'settings', :id => @project
|
|
115
|
redirect_to :action => 'settings', :id => @project
|
|
116
|
else
|
|
116
|
else
|
|
117
|
settings
|
|
117
|
settings
|
|
118
|
render :action => 'settings'
|
|
118
|
render :action => 'settings'
|
|
119
|
end
|
|
119
|
end
|
|
120
|
end
|
|
120
|
end
|
|
121
|
end
|
|
121
|
end
|
|
122
|
|
|
122
|
|
|
123
|
# Delete @project
|
|
123
|
# Delete @project
|
|
124
|
def destroy
|
|
124
|
def destroy
|
|
125
|
if request.post? and params[:confirm]
|
|
125
|
if request.post? and params[:confirm]
|
|
126
|
@project.destroy
|
|
126
|
@project.destroy
|
|
127
|
redirect_to :controller => 'admin', :action => 'projects'
|
|
127
|
redirect_to :controller => 'admin', :action => 'projects'
|
|
128
|
end
|
|
128
|
end
|
|
129
|
end
|
|
129
|
end
|
|
130
|
|
|
130
|
|
|
131
|
# Add a new issue category to @project
|
|
131
|
# Add a new issue category to @project
|
|
132
|
def add_issue_category
|
|
132
|
def add_issue_category
|
|
133
|
if request.post?
|
|
133
|
if request.post?
|
|
134
|
@issue_category = @project.issue_categories.build(params[:issue_category])
|
|
134
|
@issue_category = @project.issue_categories.build(params[:issue_category])
|
|
135
|
if @issue_category.save
|
|
135
|
if @issue_category.save
|
|
136
|
flash[:notice] = l(:notice_successful_create)
|
|
136
|
flash[:notice] = l(:notice_successful_create)
|
|
137
|
redirect_to :action => 'settings', :id => @project
|
|
137
|
redirect_to :action => 'settings', :id => @project
|
|
138
|
else
|
|
138
|
else
|
|
139
|
settings
|
|
139
|
settings
|
|
140
|
render :action => 'settings'
|
|
140
|
render :action => 'settings'
|
|
141
|
end
|
|
141
|
end
|
|
142
|
end
|
|
142
|
end
|
|
143
|
end
|
|
143
|
end
|
|
144
|
|
|
144
|
|
|
145
|
# Add a new version to @project
|
|
145
|
# Add a new version to @project
|
|
146
|
def add_version
|
|
146
|
def add_version
|
|
147
|
@version = @project.versions.build(params[:version])
|
|
147
|
@version = @project.versions.build(params[:version])
|
|
148
|
if request.post? and @version.save
|
|
148
|
if request.post? and @version.save
|
|
149
|
flash[:notice] = l(:notice_successful_create)
|
|
149
|
flash[:notice] = l(:notice_successful_create)
|
|
150
|
redirect_to :action => 'settings', :id => @project
|
|
150
|
redirect_to :action => 'settings', :id => @project
|
|
151
|
end
|
|
151
|
end
|
|
152
|
end
|
|
152
|
end
|
|
153
|
|
|
153
|
|
|
154
|
# Add a new member to @project
|
|
154
|
# Add a new member to @project
|
|
155
|
def add_member
|
|
155
|
def add_member
|
|
156
|
@member = @project.members.build(params[:member])
|
|
156
|
@member = @project.members.build(params[:member])
|
|
157
|
if request.post?
|
|
157
|
if request.post?
|
|
158
|
if @member.save
|
|
158
|
if @member.save
|
|
159
|
flash[:notice] = l(:notice_successful_create)
|
|
159
|
flash[:notice] = l(:notice_successful_create)
|
|
160
|
redirect_to :action => 'settings', :id => @project
|
|
160
|
redirect_to :action => 'settings', :id => @project
|
|
161
|
else
|
|
161
|
else
|
|
162
|
settings
|
|
162
|
settings
|
|
163
|
render :action => 'settings'
|
|
163
|
render :action => 'settings'
|
|
164
|
end
|
|
164
|
end
|
|
165
|
end
|
|
165
|
end
|
|
166
|
end
|
|
166
|
end
|
|
167
|
|
|
167
|
|
|
168
|
# Show members list of @project
|
|
168
|
# Show members list of @project
|
|
169
|
def list_members
|
|
169
|
def list_members
|
|
170
|
@members = @project.members
|
|
170
|
@members = @project.members
|
|
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
|
@categories = Enumeration::get_values('DCAT')
|
|
175
|
@categories = Enumeration::get_values('DCAT')
|
|
176
|
@document = @project.documents.build(params[:document])
|
|
176
|
@document = @project.documents.build(params[:document])
|
|
177
|
if request.post? and @document.save
|
|
177
|
if request.post? and @document.save
|
|
178
|
# Save the attachments
|
|
178
|
# Save the attachments
|
|
179
|
params[:attachments].each { |a|
|
|
179
|
params[:attachments].each { |a|
|
|
180
|
Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0
|
|
180
|
Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0
|
|
181
|
} if params[:attachments] and params[:attachments].is_a? Array
|
|
181
|
} if params[:attachments] and params[:attachments].is_a? Array
|
|
182
|
flash[:notice] = l(:notice_successful_create)
|
|
182
|
flash[:notice] = l(:notice_successful_create)
|
|
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
|
@documents = @project.documents.find :all, :include => :category
|
|
189
|
@documents = @project.documents.find :all, :include => :category
|
|
190
|
end
|
|
190
|
end
|
|
191
|
|
|
191
|
|
|
192
|
# Add a new issue to @project
|
|
192
|
# Add a new issue to @project
|
|
193
|
def add_issue
|
|
193
|
def add_issue
|
|
194
|
@tracker = Tracker.find(params[:tracker_id])
|
|
194
|
@tracker = Tracker.find(params[:tracker_id])
|
|
195
|
@priorities = Enumeration::get_values('IPRI')
|
|
195
|
@priorities = Enumeration::get_values('IPRI')
|
|
196
|
@issue = Issue.new(:project => @project, :tracker => @tracker)
|
|
196
|
@issue = Issue.new(:project => @project, :tracker => @tracker)
|
|
197
|
if request.get?
|
|
197
|
if request.get?
|
|
198
|
@issue.start_date = Date.today
|
|
198
|
@issue.start_date = Date.today
|
|
199
|
@custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
|
|
199
|
@custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
|
|
200
|
else
|
|
200
|
else
|
|
201
|
@issue.attributes = params[:issue]
|
|
201
|
@issue.attributes = params[:issue]
|
|
202
|
@issue.author_id = self.logged_in_user.id if self.logged_in_user
|
|
202
|
@issue.author_id = self.logged_in_user.id if self.logged_in_user
|
|
203
|
# Multiple file upload
|
|
203
|
# Multiple file upload
|
|
204
|
@attachments = []
|
|
204
|
@attachments = []
|
|
205
|
params[:attachments].each { |a|
|
|
205
|
params[:attachments].each { |a|
|
|
206
|
@attachments << Attachment.new(:container => @issue, :file => a, :author => logged_in_user) unless a.size == 0
|
|
206
|
@attachments << Attachment.new(:container => @issue, :file => a, :author => logged_in_user) unless a.size == 0
|
|
207
|
} if params[:attachments] and params[:attachments].is_a? Array
|
|
207
|
} if params[:attachments] and params[:attachments].is_a? Array
|
|
208
|
@custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
|
|
208
|
@custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
|
|
209
|
@issue.custom_values = @custom_values
|
|
209
|
@issue.custom_values = @custom_values
|
|
210
|
if @issue.save
|
|
210
|
if @issue.save
|
|
211
|
@attachments.each(&:save)
|
|
211
|
@attachments.each(&:save)
|
|
212
|
flash[:notice] = l(:notice_successful_create)
|
|
212
|
flash[:notice] = l(:notice_successful_create)
|
|
213
|
Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
|
213
|
Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
|
214
|
redirect_to :action => 'list_issues', :id => @project
|
|
214
|
redirect_to :action => 'list_issues', :id => @project
|
|
215
|
end
|
|
215
|
end
|
|
216
|
end
|
|
216
|
end
|
|
217
|
end
|
|
217
|
end
|
|
218
|
|
|
218
|
|
|
219
|
# Show filtered/sorted issues list of @project
|
|
219
|
# Show filtered/sorted issues list of @project
|
|
220
|
def list_issues
|
|
220
|
def list_issues
|
|
221
|
sort_init 'issues.id', 'desc'
|
|
221
|
sort_init 'issues.id', 'desc'
|
|
222
|
sort_update
|
|
222
|
sort_update
|
|
223
|
|
|
223
|
|
|
224
|
retrieve_query
|
|
224
|
retrieve_query
|
|
225
|
|
|
225
|
|
|
226
|
@results_per_page_options = [ 15, 25, 50, 100 ]
|
|
226
|
@results_per_page_options = [ 15, 25, 50, 100 ]
|
|
227
|
if params[:per_page] and @results_per_page_options.include? params[:per_page].to_i
|
|
227
|
if params[:per_page] and @results_per_page_options.include? params[:per_page].to_i
|
|
228
|
@results_per_page = params[:per_page].to_i
|
|
228
|
@results_per_page = params[:per_page].to_i
|
|
229
|
session[:results_per_page] = @results_per_page
|
|
229
|
session[:results_per_page] = @results_per_page
|
|
230
|
else
|
|
230
|
else
|
|
231
|
@results_per_page = session[:results_per_page] || 25
|
|
231
|
@results_per_page = session[:results_per_page] || 25
|
|
232
|
end
|
|
232
|
end
|
|
233
|
|
|
233
|
|
|
234
|
if @query.valid?
|
|
234
|
if @query.valid?
|
|
235
|
@issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement)
|
|
235
|
@issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement)
|
|
236
|
@issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page']
|
|
236
|
@issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page']
|
|
237
|
@issues = Issue.find :all, :order => sort_clause,
|
|
237
|
@issues = Issue.find :all, :order => sort_clause,
|
|
238
|
:include => [ :author, :status, :tracker, :project ],
|
|
238
|
:include => [ :author, :status, :tracker, :project ],
|
|
239
|
:conditions => @query.statement,
|
|
239
|
:conditions => @query.statement,
|
|
240
|
:limit => @issue_pages.items_per_page,
|
|
240
|
:limit => @issue_pages.items_per_page,
|
|
241
|
:offset => @issue_pages.current.offset
|
|
241
|
:offset => @issue_pages.current.offset
|
|
242
|
end
|
|
242
|
end
|
|
|
|
|
243
|
@trackers = Tracker.find :all
|
|
243
|
render :layout => false if request.xhr?
|
|
244
|
render :layout => false if request.xhr?
|
|
244
|
end
|
|
245
|
end
|
|
245
|
|
|
246
|
|
|
246
|
# Export filtered/sorted issues list to CSV
|
|
247
|
# Export filtered/sorted issues list to CSV
|
|
247
|
def export_issues_csv
|
|
248
|
def export_issues_csv
|
|
248
|
sort_init 'issues.id', 'desc'
|
|
249
|
sort_init 'issues.id', 'desc'
|
|
249
|
sort_update
|
|
250
|
sort_update
|
|
250
|
|
|
251
|
|
|
251
|
retrieve_query
|
|
252
|
retrieve_query
|
|
252
|
render :action => 'list_issues' and return unless @query.valid?
|
|
253
|
render :action => 'list_issues' and return unless @query.valid?
|
|
253
|
|
|
254
|
|
|
254
|
@issues = Issue.find :all, :order => sort_clause,
|
|
255
|
@issues = Issue.find :all, :order => sort_clause,
|
|
255
|
:include => [ :author, :status, :tracker, :project, :custom_values ],
|
|
256
|
:include => [ :author, :status, :tracker, :project, :custom_values ],
|
|
256
|
:conditions => @query.statement
|
|
257
|
:conditions => @query.statement
|
|
257
|
|
|
258
|
|
|
258
|
ic = Iconv.new('ISO-8859-1', 'UTF-8')
|
|
259
|
ic = Iconv.new('ISO-8859-1', 'UTF-8')
|
|
259
|
export = StringIO.new
|
|
260
|
export = StringIO.new
|
|
260
|
CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
|
|
261
|
CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
|
|
261
|
# csv header fields
|
|
262
|
# csv header fields
|
|
262
|
headers = [ "#", l(:field_status), l(:field_tracker), l(:field_subject), l(:field_author), l(:field_created_on), l(:field_updated_on) ]
|
|
263
|
headers = [ "#", l(:field_status), l(:field_tracker), l(:field_subject), l(:field_author), l(:field_created_on), l(:field_updated_on) ]
|
|
263
|
for custom_field in @project.all_custom_fields
|
|
264
|
for custom_field in @project.all_custom_fields
|
|
264
|
headers << custom_field.name
|
|
265
|
headers << custom_field.name
|
|
265
|
end
|
|
266
|
end
|
|
266
|
csv << headers.collect {|c| ic.iconv(c) }
|
|
267
|
csv << headers.collect {|c| ic.iconv(c) }
|
|
267
|
# csv lines
|
|
268
|
# csv lines
|
|
268
|
@issues.each do |issue|
|
|
269
|
@issues.each do |issue|
|
|
269
|
fields = [issue.id, issue.status.name, issue.tracker.name, issue.subject, issue.author.display_name, l_datetime(issue.created_on), l_datetime(issue.updated_on)]
|
|
270
|
fields = [issue.id, issue.status.name, issue.tracker.name, issue.subject, issue.author.display_name, l_datetime(issue.created_on), l_datetime(issue.updated_on)]
|
|
270
|
for custom_field in @project.all_custom_fields
|
|
271
|
for custom_field in @project.all_custom_fields
|
|
271
|
fields << (show_value issue.custom_value_for(custom_field))
|
|
272
|
fields << (show_value issue.custom_value_for(custom_field))
|
|
272
|
end
|
|
273
|
end
|
|
273
|
csv << fields.collect {|c| ic.iconv(c.to_s) }
|
|
274
|
csv << fields.collect {|c| ic.iconv(c.to_s) }
|
|
274
|
end
|
|
275
|
end
|
|
275
|
end
|
|
276
|
end
|
|
276
|
export.rewind
|
|
277
|
export.rewind
|
|
277
|
send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv')
|
|
278
|
send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv')
|
|
278
|
end
|
|
279
|
end
|
|
279
|
|
|
280
|
|
|
280
|
# Export filtered/sorted issues to PDF
|
|
281
|
# Export filtered/sorted issues to PDF
|
|
281
|
def export_issues_pdf
|
|
282
|
def export_issues_pdf
|
|
282
|
sort_init 'issues.id', 'desc'
|
|
283
|
sort_init 'issues.id', 'desc'
|
|
283
|
sort_update
|
|
284
|
sort_update
|
|
284
|
|
|
285
|
|
|
285
|
retrieve_query
|
|
286
|
retrieve_query
|
|
286
|
render :action => 'list_issues' and return unless @query.valid?
|
|
287
|
render :action => 'list_issues' and return unless @query.valid?
|
|
287
|
|
|
288
|
|
|
288
|
@issues = Issue.find :all, :order => sort_clause,
|
|
289
|
@issues = Issue.find :all, :order => sort_clause,
|
|
289
|
:include => [ :author, :status, :tracker, :project, :custom_values ],
|
|
290
|
:include => [ :author, :status, :tracker, :project, :custom_values ],
|
|
290
|
:conditions => @query.statement
|
|
291
|
:conditions => @query.statement
|
|
291
|
|
|
292
|
|
|
292
|
@options_for_rfpdf ||= {}
|
|
293
|
@options_for_rfpdf ||= {}
|
|
293
|
@options_for_rfpdf[:file_name] = "export.pdf"
|
|
294
|
@options_for_rfpdf[:file_name] = "export.pdf"
|
|
294
|
render :layout => false
|
|
295
|
render :layout => false
|
|
295
|
end
|
|
296
|
end
|
|
296
|
|
|
297
|
|
|
297
|
def move_issues
|
|
298
|
def move_issues
|
|
298
|
@issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids]
|
|
299
|
@issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids]
|
|
299
|
redirect_to :action => 'list_issues', :id => @project and return unless @issues
|
|
300
|
redirect_to :action => 'list_issues', :id => @project and return unless @issues
|
|
300
|
@projects = []
|
|
301
|
@projects = []
|
|
301
|
# find projects to which the user is allowed to move the issue
|
|
302
|
# find projects to which the user is allowed to move the issue
|
|
302
|
@logged_in_user.memberships.each {|m| @projects << m.project if Permission.allowed_to_role("projects/move_issues", m.role_id)}
|
|
303
|
@logged_in_user.memberships.each {|m| @projects << m.project if Permission.allowed_to_role("projects/move_issues", m.role_id)}
|
|
303
|
# issue can be moved to any tracker
|
|
304
|
# issue can be moved to any tracker
|
|
304
|
@trackers = Tracker.find(:all)
|
|
305
|
@trackers = Tracker.find(:all)
|
|
305
|
if request.post? and params[:new_project_id] and params[:new_tracker_id]
|
|
306
|
if request.post? and params[:new_project_id] and params[:new_tracker_id]
|
|
306
|
new_project = Project.find(params[:new_project_id])
|
|
307
|
new_project = Project.find(params[:new_project_id])
|
|
307
|
new_tracker = Tracker.find(params[:new_tracker_id])
|
|
308
|
new_tracker = Tracker.find(params[:new_tracker_id])
|
|
308
|
@issues.each { |i|
|
|
309
|
@issues.each { |i|
|
|
309
|
# project dependent properties
|
|
310
|
# project dependent properties
|
|
310
|
unless i.project_id == new_project.id
|
|
311
|
unless i.project_id == new_project.id
|
|
311
|
i.category = nil
|
|
312
|
i.category = nil
|
|
312
|
i.fixed_version = nil
|
|
313
|
i.fixed_version = nil
|
|
313
|
end
|
|
314
|
end
|
|
314
|
# move the issue
|
|
315
|
# move the issue
|
|
315
|
i.project = new_project
|
|
316
|
i.project = new_project
|
|
316
|
i.tracker = new_tracker
|
|
317
|
i.tracker = new_tracker
|
|
317
|
i.save
|
|
318
|
i.save
|
|
318
|
}
|
|
319
|
}
|
|
319
|
flash[:notice] = l(:notice_successful_update)
|
|
320
|
flash[:notice] = l(:notice_successful_update)
|
|
320
|
redirect_to :action => 'list_issues', :id => @project
|
|
321
|
redirect_to :action => 'list_issues', :id => @project
|
|
321
|
end
|
|
322
|
end
|
|
322
|
end
|
|
323
|
end
|
|
323
|
|
|
324
|
|
|
324
|
def add_query
|
|
325
|
def add_query
|
|
325
|
@query = Query.new(params[:query])
|
|
326
|
@query = Query.new(params[:query])
|
|
326
|
@query.project = @project
|
|
327
|
@query.project = @project
|
|
327
|
@query.user = logged_in_user
|
|
328
|
@query.user = logged_in_user
|
|
328
|
|
|
329
|
|
|
329
|
params[:fields].each do |field|
|
|
330
|
params[:fields].each do |field|
|
|
330
|
@query.add_filter(field, params[:operators][field], params[:values][field])
|
|
331
|
@query.add_filter(field, params[:operators][field], params[:values][field])
|
|
331
|
end if params[:fields]
|
|
332
|
end if params[:fields]
|
|
332
|
|
|
333
|
|
|
333
|
if request.post? and @query.save
|
|
334
|
if request.post? and @query.save
|
|
334
|
flash[:notice] = l(:notice_successful_create)
|
|
335
|
flash[:notice] = l(:notice_successful_create)
|
|
335
|
redirect_to :controller => 'reports', :action => 'issue_report', :id => @project
|
|
336
|
redirect_to :controller => 'reports', :action => 'issue_report', :id => @project
|
|
336
|
end
|
|
337
|
end
|
|
337
|
render :layout => false if request.xhr?
|
|
338
|
render :layout => false if request.xhr?
|
|
338
|
end
|
|
339
|
end
|
|
339
|
|
|
340
|
|
|
340
|
# Add a news to @project
|
|
341
|
# Add a news to @project
|
|
341
|
def add_news
|
|
342
|
def add_news
|
|
342
|
@news = News.new(:project => @project)
|
|
343
|
@news = News.new(:project => @project)
|
|
343
|
if request.post?
|
|
344
|
if request.post?
|
|
344
|
@news.attributes = params[:news]
|
|
345
|
@news.attributes = params[:news]
|
|
345
|
@news.author_id = self.logged_in_user.id if self.logged_in_user
|
|
346
|
@news.author_id = self.logged_in_user.id if self.logged_in_user
|
|
346
|
if @news.save
|
|
347
|
if @news.save
|
|
347
|
flash[:notice] = l(:notice_successful_create)
|
|
348
|
flash[:notice] = l(:notice_successful_create)
|
|
348
|
redirect_to :action => 'list_news', :id => @project
|
|
349
|
redirect_to :action => 'list_news', :id => @project
|
|
349
|
end
|
|
350
|
end
|
|
350
|
end
|
|
351
|
end
|
|
351
|
end
|
|
352
|
end
|
|
352
|
|
|
353
|
|
|
353
|
# Show news list of @project
|
|
354
|
# Show news list of @project
|
|
354
|
def list_news
|
|
355
|
def list_news
|
|
355
|
@news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC"
|
|
356
|
@news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC"
|
|
356
|
render :action => "list_news", :layout => false if request.xhr?
|
|
357
|
render :action => "list_news", :layout => false if request.xhr?
|
|
357
|
end
|
|
358
|
end
|
|
358
|
|
|
359
|
|
|
359
|
def add_file
|
|
360
|
def add_file
|
|
360
|
if request.post?
|
|
361
|
if request.post?
|
|
361
|
@version = @project.versions.find_by_id(params[:version_id])
|
|
362
|
@version = @project.versions.find_by_id(params[:version_id])
|
|
362
|
# Save the attachments
|
|
363
|
# Save the attachments
|
|
363
|
params[:attachments].each { |a|
|
|
364
|
params[:attachments].each { |a|
|
|
364
|
Attachment.create(:container => @version, :file => a, :author => logged_in_user) unless a.size == 0
|
|
365
|
Attachment.create(:container => @version, :file => a, :author => logged_in_user) unless a.size == 0
|
|
365
|
} if params[:attachments] and params[:attachments].is_a? Array
|
|
366
|
} if params[:attachments] and params[:attachments].is_a? Array
|
|
366
|
redirect_to :controller => 'projects', :action => 'list_files', :id => @project
|
|
367
|
redirect_to :controller => 'projects', :action => 'list_files', :id => @project
|
|
367
|
end
|
|
368
|
end
|
|
368
|
@versions = @project.versions
|
|
369
|
@versions = @project.versions
|
|
369
|
end
|
|
370
|
end
|
|
370
|
|
|
371
|
|
|
371
|
def list_files
|
|
372
|
def list_files
|
|
372
|
@versions = @project.versions
|
|
373
|
@versions = @project.versions
|
|
373
|
end
|
|
374
|
end
|
|
374
|
|
|
375
|
|
|
375
|
# Show changelog for @project
|
|
376
|
# Show changelog for @project
|
|
376
|
def changelog
|
|
377
|
def changelog
|
|
377
|
@trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true])
|
|
378
|
@trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true])
|
|
378
|
if request.get?
|
|
379
|
if request.get?
|
|
379
|
@selected_tracker_ids = @trackers.collect {|t| t.id.to_s }
|
|
380
|
@selected_tracker_ids = @trackers.collect {|t| t.id.to_s }
|
|
380
|
else
|
|
381
|
else
|
|
381
|
@selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array
|
|
382
|
@selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array
|
|
382
|
end
|
|
383
|
end
|
|
383
|
@selected_tracker_ids ||= []
|
|
384
|
@selected_tracker_ids ||= []
|
|
384
|
@fixed_issues = @project.issues.find(:all,
|
|
385
|
@fixed_issues = @project.issues.find(:all,
|
|
385
|
:include => [ :fixed_version, :status, :tracker ],
|
|
386
|
:include => [ :fixed_version, :status, :tracker ],
|
|
386
|
:conditions => [ "issue_statuses.is_closed=? and issues.tracker_id in (#{@selected_tracker_ids.join(',')}) and issues.fixed_version_id is not null", true],
|
|
387
|
:conditions => [ "issue_statuses.is_closed=? and issues.tracker_id in (#{@selected_tracker_ids.join(',')}) and issues.fixed_version_id is not null", true],
|
|
387
|
:order => "versions.effective_date DESC, issues.id DESC"
|
|
388
|
:order => "versions.effective_date DESC, issues.id DESC"
|
|
388
|
) unless @selected_tracker_ids.empty?
|
|
389
|
) unless @selected_tracker_ids.empty?
|
|
389
|
@fixed_issues ||= []
|
|
390
|
@fixed_issues ||= []
|
|
390
|
end
|
|
391
|
end
|
|
391
|
|
|
392
|
|
|
392
|
def activity
|
|
393
|
def activity
|
|
393
|
if params[:year] and params[:year].to_i > 1900
|
|
394
|
if params[:year] and params[:year].to_i > 1900
|
|
394
|
@year = params[:year].to_i
|
|
395
|
@year = params[:year].to_i
|
|
395
|
if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
|
|
396
|
if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
|
|
396
|
@month = params[:month].to_i
|
|
397
|
@month = params[:month].to_i
|
|
397
|
end
|
|
398
|
end
|
|
398
|
end
|
|
399
|
end
|
|
399
|
@year ||= Date.today.year
|
|
400
|
@year ||= Date.today.year
|
|
400
|
@month ||= Date.today.month
|
|
401
|
@month ||= Date.today.month
|
|
401
|
|
|
402
|
|
|
402
|
@date_from = Date.civil(@year, @month, 1)
|
|
403
|
@date_from = Date.civil(@year, @month, 1)
|
|
403
|
@date_to = (@date_from >> 1)-1
|
|
404
|
@date_to = (@date_from >> 1)-1
|
|
404
|
|
|
405
|
|
|
405
|
@events_by_day = {}
|
|
406
|
@events_by_day = {}
|
|
406
|
|
|
407
|
|
|
407
|
unless params[:show_issues] == "0"
|
|
408
|
unless params[:show_issues] == "0"
|
|
408
|
@project.issues.find(:all, :include => [:author, :status], :conditions => ["issues.created_on>=? and issues.created_on<=?", @date_from, @date_to] ).each { |i|
|
|
409
|
@project.issues.find(:all, :include => [:author, :status], :conditions => ["issues.created_on>=? and issues.created_on<=?", @date_from, @date_to] ).each { |i|
|
|
409
|
@events_by_day[i.created_on.to_date] ||= []
|
|
410
|
@events_by_day[i.created_on.to_date] ||= []
|
|
410
|
@events_by_day[i.created_on.to_date] << i
|
|
411
|
@events_by_day[i.created_on.to_date] << i
|
|
411
|
}
|
|
412
|
}
|
|
412
|
@show_issues = 1
|
|
413
|
@show_issues = 1
|
|
413
|
end
|
|
414
|
end
|
|
414
|
|
|
415
|
|
|
415
|
unless params[:show_news] == "0"
|
|
416
|
unless params[:show_news] == "0"
|
|
416
|
@project.news.find(:all, :conditions => ["news.created_on>=? and news.created_on<=?", @date_from, @date_to], :include => :author ).each { |i|
|
|
417
|
@project.news.find(:all, :conditions => ["news.created_on>=? and news.created_on<=?", @date_from, @date_to], :include => :author ).each { |i|
|
|
417
|
@events_by_day[i.created_on.to_date] ||= []
|
|
418
|
@events_by_day[i.created_on.to_date] ||= []
|
|
418
|
@events_by_day[i.created_on.to_date] << i
|
|
419
|
@events_by_day[i.created_on.to_date] << i
|
|
419
|
}
|
|
420
|
}
|
|
420
|
@show_news = 1
|
|
421
|
@show_news = 1
|
|
421
|
end
|
|
422
|
end
|
|
422
|
|
|
423
|
|
|
423
|
unless params[:show_files] == "0"
|
|
424
|
unless params[:show_files] == "0"
|
|
424
|
Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN versions ON versions.id = attachments.container_id", :conditions => ["attachments.container_type='Version' and versions.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i|
|
|
425
|
Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN versions ON versions.id = attachments.container_id", :conditions => ["attachments.container_type='Version' and versions.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i|
|
|
425
|
@events_by_day[i.created_on.to_date] ||= []
|
|
426
|
@events_by_day[i.created_on.to_date] ||= []
|
|
426
|
@events_by_day[i.created_on.to_date] << i
|
|
427
|
@events_by_day[i.created_on.to_date] << i
|
|
427
|
}
|
|
428
|
}
|
|
428
|
@show_files = 1
|
|
429
|
@show_files = 1
|
|
429
|
end
|
|
430
|
end
|
|
430
|
|
|
431
|
|
|
431
|
unless params[:show_documents] == "0"
|
|
432
|
unless params[:show_documents] == "0"
|
|
432
|
@project.documents.find(:all, :conditions => ["documents.created_on>=? and documents.created_on<=?", @date_from, @date_to] ).each { |i|
|
|
433
|
@project.documents.find(:all, :conditions => ["documents.created_on>=? and documents.created_on<=?", @date_from, @date_to] ).each { |i|
|
|
433
|
@events_by_day[i.created_on.to_date] ||= []
|
|
434
|
@events_by_day[i.created_on.to_date] ||= []
|
|
434
|
@events_by_day[i.created_on.to_date] << i
|
|
435
|
@events_by_day[i.created_on.to_date] << i
|
|
435
|
}
|
|
436
|
}
|
|
436
|
Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN documents ON documents.id = attachments.container_id", :conditions => ["attachments.container_type='Document' and documents.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i|
|
|
437
|
Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN documents ON documents.id = attachments.container_id", :conditions => ["attachments.container_type='Document' and documents.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i|
|
|
437
|
@events_by_day[i.created_on.to_date] ||= []
|
|
438
|
@events_by_day[i.created_on.to_date] ||= []
|
|
438
|
@events_by_day[i.created_on.to_date] << i
|
|
439
|
@events_by_day[i.created_on.to_date] << i
|
|
439
|
}
|
|
440
|
}
|
|
440
|
@show_documents = 1
|
|
441
|
@show_documents = 1
|
|
441
|
end
|
|
442
|
end
|
|
442
|
|
|
443
|
|
|
443
|
render :layout => false if request.xhr?
|
|
444
|
render :layout => false if request.xhr?
|
|
444
|
end
|
|
445
|
end
|
|
445
|
|
|
446
|
|
|
446
|
def calendar
|
|
447
|
def calendar
|
|
447
|
if params[:year] and params[:year].to_i > 1900
|
|
448
|
if params[:year] and params[:year].to_i > 1900
|
|
448
|
@year = params[:year].to_i
|
|
449
|
@year = params[:year].to_i
|
|
449
|
if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
|
|
450
|
if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
|
|
450
|
@month = params[:month].to_i
|
|
451
|
@month = params[:month].to_i
|
|
451
|
end
|
|
452
|
end
|
|
452
|
end
|
|
453
|
end
|
|
453
|
@year ||= Date.today.year
|
|
454
|
@year ||= Date.today.year
|
|
454
|
@month ||= Date.today.month
|
|
455
|
@month ||= Date.today.month
|
|
455
|
|
|
456
|
|
|
456
|
@date_from = Date.civil(@year, @month, 1)
|
|
457
|
@date_from = Date.civil(@year, @month, 1)
|
|
457
|
@date_to = (@date_from >> 1)-1
|
|
458
|
@date_to = (@date_from >> 1)-1
|
|
458
|
# start on monday
|
|
459
|
# start on monday
|
|
459
|
@date_from = @date_from - (@date_from.cwday-1)
|
|
460
|
@date_from = @date_from - (@date_from.cwday-1)
|
|
460
|
# finish on sunday
|
|
461
|
# finish on sunday
|
|
461
|
@date_to = @date_to + (7-@date_to.cwday)
|
|
462
|
@date_to = @date_to + (7-@date_to.cwday)
|
|
462
|
|
|
463
|
|
|
463
|
@issues = @project.issues.find(:all, :include => :tracker, :conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?))", @date_from, @date_to, @date_from, @date_to])
|
|
464
|
@issues = @project.issues.find(:all, :include => :tracker, :conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?))", @date_from, @date_to, @date_from, @date_to])
|
|
464
|
render :layout => false if request.xhr?
|
|
465
|
render :layout => false if request.xhr?
|
|
465
|
end
|
|
466
|
end
|
|
466
|
|
|
467
|
|
|
467
|
def gantt
|
|
468
|
def gantt
|
|
468
|
if params[:year] and params[:year].to_i >0
|
|
469
|
if params[:year] and params[:year].to_i >0
|
|
469
|
@year_from = params[:year].to_i
|
|
470
|
@year_from = params[:year].to_i
|
|
470
|
if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12
|
|
471
|
if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12
|
|
471
|
@month_from = params[:month].to_i
|
|
472
|
@month_from = params[:month].to_i
|
|
472
|
else
|
|
473
|
else
|
|
473
|
@month_from = 1
|
|
474
|
@month_from = 1
|
|
474
|
end
|
|
475
|
end
|
|
475
|
else
|
|
476
|
else
|
|
476
|
@month_from ||= (Date.today << 1).month
|
|
477
|
@month_from ||= (Date.today << 1).month
|
|
477
|
@year_from ||= (Date.today << 1).year
|
|
478
|
@year_from ||= (Date.today << 1).year
|
|
478
|
end
|
|
479
|
end
|
|
479
|
|
|
480
|
|
|
480
|
@zoom = (params[:zoom].to_i > 0 and params[:zoom].to_i < 5) ? params[:zoom].to_i : 2
|
|
481
|
@zoom = (params[:zoom].to_i > 0 and params[:zoom].to_i < 5) ? params[:zoom].to_i : 2
|
|
481
|
@months = (params[:months].to_i > 0 and params[:months].to_i < 25) ? params[:months].to_i : 6
|
|
482
|
@months = (params[:months].to_i > 0 and params[:months].to_i < 25) ? params[:months].to_i : 6
|
|
482
|
|
|
483
|
|
|
483
|
@date_from = Date.civil(@year_from, @month_from, 1)
|
|
484
|
@date_from = Date.civil(@year_from, @month_from, 1)
|
|
484
|
@date_to = (@date_from >> @months) - 1
|
|
485
|
@date_to = (@date_from >> @months) - 1
|
|
485
|
@issues = @project.issues.find(:all, :order => "start_date, due_date", :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)", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to])
|
|
486
|
@issues = @project.issues.find(:all, :order => "start_date, due_date", :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)", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to])
|
|
486
|
|
|
487
|
|
|
487
|
if params[:output]=='pdf'
|
|
488
|
if params[:output]=='pdf'
|
|
488
|
@options_for_rfpdf ||= {}
|
|
489
|
@options_for_rfpdf ||= {}
|
|
489
|
@options_for_rfpdf[:file_name] = "gantt.pdf"
|
|
490
|
@options_for_rfpdf[:file_name] = "gantt.pdf"
|
|
490
|
render :template => "projects/gantt.rfpdf", :layout => false
|
|
491
|
render :template => "projects/gantt.rfpdf", :layout => false
|
|
491
|
else
|
|
492
|
else
|
|
492
|
render :template => "projects/gantt.rhtml"
|
|
493
|
render :template => "projects/gantt.rhtml"
|
|
493
|
end
|
|
494
|
end
|
|
494
|
end
|
|
495
|
end
|
|
495
|
|
|
496
|
|
|
496
|
private
|
|
497
|
private
|
|
497
|
# Find project of id params[:id]
|
|
498
|
# Find project of id params[:id]
|
|
498
|
# if not found, redirect to project list
|
|
499
|
# if not found, redirect to project list
|
|
499
|
# Used as a before_filter
|
|
500
|
# Used as a before_filter
|
|
500
|
def find_project
|
|
501
|
def find_project
|
|
501
|
@project = Project.find(params[:id])
|
|
502
|
@project = Project.find(params[:id])
|
|
502
|
@html_title = @project.name
|
|
503
|
@html_title = @project.name
|
|
503
|
rescue ActiveRecord::RecordNotFound
|
|
504
|
rescue ActiveRecord::RecordNotFound
|
|
504
|
render_404
|
|
505
|
render_404
|
|
505
|
end
|
|
506
|
end
|
|
506
|
|
|
507
|
|
|
507
|
# Retrieve query from session or build a new query
|
|
508
|
# Retrieve query from session or build a new query
|
|
508
|
def retrieve_query
|
|
509
|
def retrieve_query
|
|
509
|
if params[:query_id]
|
|
510
|
if params[:query_id]
|
|
510
|
@query = @project.queries.find(params[:query_id])
|
|
511
|
@query = @project.queries.find(params[:query_id])
|
|
511
|
else
|
|
512
|
else
|
|
512
|
if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id
|
|
513
|
if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id
|
|
513
|
# Give it a name, required to be valid
|
|
514
|
# Give it a name, required to be valid
|
|
514
|
@query = Query.new(:name => "_")
|
|
515
|
@query = Query.new(:name => "_")
|
|
515
|
@query.project = @project
|
|
516
|
@query.project = @project
|
|
516
|
if params[:fields] and params[:fields].is_a? Array
|
|
517
|
if params[:fields] and params[:fields].is_a? Array
|
|
517
|
params[:fields].each do |field|
|
|
518
|
params[:fields].each do |field|
|
|
518
|
@query.add_filter(field, params[:operators][field], params[:values][field])
|
|
519
|
@query.add_filter(field, params[:operators][field], params[:values][field])
|
|
519
|
end
|
|
520
|
end
|
|
520
|
else
|
|
521
|
else
|
|
521
|
@query.available_filters.keys.each do |field|
|
|
522
|
@query.available_filters.keys.each do |field|
|
|
522
|
@query.add_short_filter(field, params[field]) if params[field]
|
|
523
|
@query.add_short_filter(field, params[field]) if params[field]
|
|
523
|
end
|
|
524
|
end
|
|
524
|
end
|
|
525
|
end
|
|
525
|
session[:query] = @query
|
|
526
|
session[:query] = @query
|
|
526
|
else
|
|
527
|
else
|
|
527
|
@query = session[:query]
|
|
528
|
@query = session[:query]
|
|
528
|
end
|
|
529
|
end
|
|
529
|
end
|
|
530
|
end
|
|
530
|
end
|
|
531
|
end
|
|
531
|
end
|
|
532
|
end
|