@@ -1,590 +1,592 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require 'csv' |
|
19 | 19 | |
|
20 | 20 | class ProjectsController < ApplicationController |
|
21 | 21 | layout 'base' |
|
22 | 22 | before_filter :find_project, :authorize, :except => [ :index, :list, :add ] |
|
23 | 23 | before_filter :require_admin, :only => [ :add, :destroy ] |
|
24 | 24 | |
|
25 | 25 | helper :sort |
|
26 | 26 | include SortHelper |
|
27 | 27 | helper :custom_fields |
|
28 | 28 | include CustomFieldsHelper |
|
29 | 29 | helper :ifpdf |
|
30 | 30 | include IfpdfHelper |
|
31 | 31 | helper IssuesHelper |
|
32 | 32 | helper :queries |
|
33 | 33 | include QueriesHelper |
|
34 | 34 | |
|
35 | 35 | def index |
|
36 | 36 | list |
|
37 | 37 | render :action => 'list' unless request.xhr? |
|
38 | 38 | end |
|
39 | 39 | |
|
40 | 40 | # Lists public projects |
|
41 | 41 | def list |
|
42 | 42 | sort_init 'name', 'asc' |
|
43 | 43 | sort_update |
|
44 | 44 | @project_count = Project.count(:all, :conditions => ["is_public=?", true]) |
|
45 | 45 | @project_pages = Paginator.new self, @project_count, |
|
46 | 46 | 15, |
|
47 | 47 | params['page'] |
|
48 | 48 | @projects = Project.find :all, :order => sort_clause, |
|
49 | 49 | :conditions => ["is_public=?", true], |
|
50 | 50 | :limit => @project_pages.items_per_page, |
|
51 | 51 | :offset => @project_pages.current.offset |
|
52 | 52 | |
|
53 | 53 | render :action => "list", :layout => false if request.xhr? |
|
54 | 54 | end |
|
55 | 55 | |
|
56 | 56 | # Add a new project |
|
57 | 57 | def add |
|
58 | 58 | @custom_fields = IssueCustomField.find(:all) |
|
59 | 59 | @root_projects = Project.find(:all, :conditions => "parent_id is null") |
|
60 | 60 | @project = Project.new(params[:project]) |
|
61 | 61 | if request.get? |
|
62 | 62 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) } |
|
63 | 63 | else |
|
64 | 64 | @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] |
|
65 | 65 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) } |
|
66 | 66 | @project.custom_values = @custom_values |
|
67 | 67 | if params[:repository_enabled] && params[:repository_enabled] == "1" |
|
68 | 68 | @project.repository = Repository.new |
|
69 | 69 | @project.repository.attributes = params[:repository] |
|
70 | 70 | end |
|
71 | 71 | if @project.save |
|
72 | 72 | flash[:notice] = l(:notice_successful_create) |
|
73 | 73 | redirect_to :controller => 'admin', :action => 'projects' |
|
74 | 74 | end |
|
75 | 75 | end |
|
76 | 76 | end |
|
77 | 77 | |
|
78 | 78 | # Show @project |
|
79 | 79 | def show |
|
80 | 80 | @custom_values = @project.custom_values.find(:all, :include => :custom_field) |
|
81 | 81 | @members = @project.members.find(:all, :include => [:user, :role]) |
|
82 | 82 | @subprojects = @project.children if @project.children.size > 0 |
|
83 | 83 | @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC") |
|
84 | 84 | @trackers = Tracker.find(:all, :order => 'position') |
|
85 | 85 | @open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN issue_statuses ON issue_statuses.id = issues.status_id", :conditions => ["project_id=? and issue_statuses.is_closed=?", @project.id, false]) |
|
86 | 86 | @total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id]) |
|
87 | 87 | end |
|
88 | 88 | |
|
89 | 89 | def settings |
|
90 | 90 | @root_projects = Project::find(:all, :conditions => ["parent_id is null and id <> ?", @project.id]) |
|
91 | 91 | @custom_fields = IssueCustomField.find(:all) |
|
92 | 92 | @issue_category ||= IssueCategory.new |
|
93 | 93 | @member ||= @project.members.new |
|
94 | 94 | @roles = Role.find(:all, :order => 'position') |
|
95 | 95 | @users = User.find_active(:all) - @project.users |
|
96 | 96 | @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) } |
|
97 | 97 | end |
|
98 | 98 | |
|
99 | 99 | # Edit @project |
|
100 | 100 | def edit |
|
101 | 101 | if request.post? |
|
102 | 102 | @project.custom_fields = IssueCustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] |
|
103 | 103 | if params[:custom_fields] |
|
104 | 104 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) } |
|
105 | 105 | @project.custom_values = @custom_values |
|
106 | 106 | end |
|
107 | 107 | if params[:repository_enabled] |
|
108 | 108 | case params[:repository_enabled] |
|
109 | 109 | when "0" |
|
110 | 110 | @project.repository = nil |
|
111 | 111 | when "1" |
|
112 | 112 | @project.repository ||= Repository.new |
|
113 | 113 | @project.repository.update_attributes params[:repository] |
|
114 | 114 | end |
|
115 | 115 | end |
|
116 | 116 | @project.attributes = params[:project] |
|
117 | 117 | if @project.save |
|
118 | 118 | flash[:notice] = l(:notice_successful_update) |
|
119 | 119 | redirect_to :action => 'settings', :id => @project |
|
120 | 120 | else |
|
121 | 121 | settings |
|
122 | 122 | render :action => 'settings' |
|
123 | 123 | end |
|
124 | 124 | end |
|
125 | 125 | end |
|
126 | 126 | |
|
127 | 127 | # Delete @project |
|
128 | 128 | def destroy |
|
129 | 129 | if request.post? and params[:confirm] |
|
130 | 130 | @project.destroy |
|
131 | 131 | redirect_to :controller => 'admin', :action => 'projects' |
|
132 | 132 | end |
|
133 | 133 | end |
|
134 | 134 | |
|
135 | 135 | # Add a new issue category to @project |
|
136 | 136 | def add_issue_category |
|
137 | 137 | if request.post? |
|
138 | 138 | @issue_category = @project.issue_categories.build(params[:issue_category]) |
|
139 | 139 | if @issue_category.save |
|
140 | 140 | flash[:notice] = l(:notice_successful_create) |
|
141 | 141 | redirect_to :action => 'settings', :tab => 'categories', :id => @project |
|
142 | 142 | else |
|
143 | 143 | settings |
|
144 | 144 | render :action => 'settings' |
|
145 | 145 | end |
|
146 | 146 | end |
|
147 | 147 | end |
|
148 | 148 | |
|
149 | 149 | # Add a new version to @project |
|
150 | 150 | def add_version |
|
151 | 151 | @version = @project.versions.build(params[:version]) |
|
152 | 152 | if request.post? and @version.save |
|
153 | 153 | flash[:notice] = l(:notice_successful_create) |
|
154 | 154 | redirect_to :action => 'settings', :tab => 'versions', :id => @project |
|
155 | 155 | end |
|
156 | 156 | end |
|
157 | 157 | |
|
158 | 158 | # Add a new member to @project |
|
159 | 159 | def add_member |
|
160 | 160 | @member = @project.members.build(params[:member]) |
|
161 | 161 | if request.post? |
|
162 | 162 | if @member.save |
|
163 | 163 | flash[:notice] = l(:notice_successful_create) |
|
164 | 164 | redirect_to :action => 'settings', :tab => 'members', :id => @project |
|
165 | 165 | else |
|
166 | 166 | settings |
|
167 | 167 | render :action => 'settings' |
|
168 | 168 | end |
|
169 | 169 | end |
|
170 | 170 | end |
|
171 | 171 | |
|
172 | 172 | # Show members list of @project |
|
173 | 173 | def list_members |
|
174 | 174 | @members = @project.members.find(:all) |
|
175 | 175 | end |
|
176 | 176 | |
|
177 | 177 | # Add a new document to @project |
|
178 | 178 | def add_document |
|
179 | 179 | @categories = Enumeration::get_values('DCAT') |
|
180 | 180 | @document = @project.documents.build(params[:document]) |
|
181 | 181 | if request.post? and @document.save |
|
182 | 182 | # Save the attachments |
|
183 | 183 | params[:attachments].each { |a| |
|
184 | 184 | Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0 |
|
185 | 185 | } if params[:attachments] and params[:attachments].is_a? Array |
|
186 | 186 | flash[:notice] = l(:notice_successful_create) |
|
187 | 187 | Mailer.deliver_document_add(@document) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? |
|
188 | 188 | redirect_to :action => 'list_documents', :id => @project |
|
189 | 189 | end |
|
190 | 190 | end |
|
191 | 191 | |
|
192 | 192 | # Show documents list of @project |
|
193 | 193 | def list_documents |
|
194 | 194 | @documents = @project.documents.find :all, :include => :category |
|
195 | 195 | end |
|
196 | 196 | |
|
197 | 197 | # Add a new issue to @project |
|
198 | 198 | def add_issue |
|
199 | 199 | @tracker = Tracker.find(params[:tracker_id]) |
|
200 | 200 | @priorities = Enumeration::get_values('IPRI') |
|
201 | 201 | @issue = Issue.new(:project => @project, :tracker => @tracker) |
|
202 | 202 | if request.get? |
|
203 | 203 | @issue.start_date = Date.today |
|
204 | 204 | @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) } |
|
205 | 205 | else |
|
206 | 206 | @issue.attributes = params[:issue] |
|
207 | 207 | @issue.author_id = self.logged_in_user.id if self.logged_in_user |
|
208 | 208 | # Multiple file upload |
|
209 | 209 | @attachments = [] |
|
210 | 210 | params[:attachments].each { |a| |
|
211 | 211 | @attachments << Attachment.new(:container => @issue, :file => a, :author => logged_in_user) unless a.size == 0 |
|
212 | 212 | } if params[:attachments] and params[:attachments].is_a? Array |
|
213 | 213 | @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]) } |
|
214 | 214 | @issue.custom_values = @custom_values |
|
215 | 215 | if @issue.save |
|
216 | 216 | @attachments.each(&:save) |
|
217 | 217 | flash[:notice] = l(:notice_successful_create) |
|
218 | 218 | Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? |
|
219 | 219 | redirect_to :action => 'list_issues', :id => @project |
|
220 | 220 | end |
|
221 | 221 | end |
|
222 | 222 | end |
|
223 | 223 | |
|
224 | 224 | # Show filtered/sorted issues list of @project |
|
225 | 225 | def list_issues |
|
226 | 226 | sort_init 'issues.id', 'desc' |
|
227 | 227 | sort_update |
|
228 | 228 | |
|
229 | 229 | retrieve_query |
|
230 | 230 | |
|
231 | 231 | @results_per_page_options = [ 15, 25, 50, 100 ] |
|
232 | 232 | if params[:per_page] and @results_per_page_options.include? params[:per_page].to_i |
|
233 | 233 | @results_per_page = params[:per_page].to_i |
|
234 | 234 | session[:results_per_page] = @results_per_page |
|
235 | 235 | else |
|
236 | 236 | @results_per_page = session[:results_per_page] || 25 |
|
237 | 237 | end |
|
238 | 238 | |
|
239 | 239 | if @query.valid? |
|
240 | 240 | @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement) |
|
241 | 241 | @issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page'] |
|
242 | 242 | @issues = Issue.find :all, :order => sort_clause, |
|
243 | 243 | :include => [ :author, :status, :tracker, :project, :priority ], |
|
244 | 244 | :conditions => @query.statement, |
|
245 | 245 | :limit => @issue_pages.items_per_page, |
|
246 | 246 | :offset => @issue_pages.current.offset |
|
247 | 247 | end |
|
248 | 248 | @trackers = Tracker.find :all, :order => 'position' |
|
249 | 249 | render :layout => false if request.xhr? |
|
250 | 250 | end |
|
251 | 251 | |
|
252 | 252 | # Export filtered/sorted issues list to CSV |
|
253 | 253 | def export_issues_csv |
|
254 | 254 | sort_init 'issues.id', 'desc' |
|
255 | 255 | sort_update |
|
256 | 256 | |
|
257 | 257 | retrieve_query |
|
258 | 258 | render :action => 'list_issues' and return unless @query.valid? |
|
259 | 259 | |
|
260 | 260 | @issues = Issue.find :all, :order => sort_clause, |
|
261 | 261 | :include => [ :author, :status, :tracker, :priority, {:custom_values => :custom_field} ], |
|
262 | 262 | :conditions => @query.statement, |
|
263 | 263 | :limit => Setting.issues_export_limit |
|
264 | 264 | |
|
265 | 265 | ic = Iconv.new('ISO-8859-1', 'UTF-8') |
|
266 | 266 | export = StringIO.new |
|
267 | 267 | CSV::Writer.generate(export, l(:general_csv_separator)) do |csv| |
|
268 | 268 | # csv header fields |
|
269 | 269 | headers = [ "#", l(:field_status), |
|
270 | 270 | l(:field_tracker), |
|
271 | 271 | l(:field_priority), |
|
272 | 272 | l(:field_subject), |
|
273 | 273 | l(:field_author), |
|
274 | 274 | l(:field_start_date), |
|
275 | 275 | l(:field_due_date), |
|
276 | 276 | l(:field_done_ratio), |
|
277 | 277 | l(:field_created_on), |
|
278 | 278 | l(:field_updated_on) |
|
279 | 279 | ] |
|
280 | 280 | for custom_field in @project.all_custom_fields |
|
281 | 281 | headers << custom_field.name |
|
282 | 282 | end |
|
283 | 283 | csv << headers.collect {|c| ic.iconv(c) } |
|
284 | 284 | # csv lines |
|
285 | 285 | @issues.each do |issue| |
|
286 | 286 | fields = [issue.id, issue.status.name, |
|
287 | 287 | issue.tracker.name, |
|
288 | 288 | issue.priority.name, |
|
289 | 289 | issue.subject, |
|
290 | 290 | issue.author.display_name, |
|
291 | 291 | issue.start_date ? l_date(issue.start_date) : nil, |
|
292 | 292 | issue.due_date ? l_date(issue.due_date) : nil, |
|
293 | 293 | issue.done_ratio, |
|
294 | 294 | l_datetime(issue.created_on), |
|
295 | 295 | l_datetime(issue.updated_on) |
|
296 | 296 | ] |
|
297 | 297 | for custom_field in @project.all_custom_fields |
|
298 | 298 | fields << (show_value issue.custom_value_for(custom_field)) |
|
299 | 299 | end |
|
300 | 300 | csv << fields.collect {|c| ic.iconv(c.to_s) } |
|
301 | 301 | end |
|
302 | 302 | end |
|
303 | 303 | export.rewind |
|
304 | 304 | send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv') |
|
305 | 305 | end |
|
306 | 306 | |
|
307 | 307 | # Export filtered/sorted issues to PDF |
|
308 | 308 | def export_issues_pdf |
|
309 | 309 | sort_init 'issues.id', 'desc' |
|
310 | 310 | sort_update |
|
311 | 311 | |
|
312 | 312 | retrieve_query |
|
313 | 313 | render :action => 'list_issues' and return unless @query.valid? |
|
314 | 314 | |
|
315 | 315 | @issues = Issue.find :all, :order => sort_clause, |
|
316 | 316 | :include => [ :author, :status, :tracker, :priority ], |
|
317 | 317 | :conditions => @query.statement, |
|
318 | 318 | :limit => Setting.issues_export_limit |
|
319 | 319 | |
|
320 | 320 | @options_for_rfpdf ||= {} |
|
321 | 321 | @options_for_rfpdf[:file_name] = "export.pdf" |
|
322 | 322 | render :layout => false |
|
323 | 323 | end |
|
324 | 324 | |
|
325 | 325 | def move_issues |
|
326 | 326 | @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids] |
|
327 | 327 | redirect_to :action => 'list_issues', :id => @project and return unless @issues |
|
328 | 328 | @projects = [] |
|
329 | 329 | # find projects to which the user is allowed to move the issue |
|
330 | 330 | @logged_in_user.memberships.each {|m| @projects << m.project if Permission.allowed_to_role("projects/move_issues", m.role_id)} |
|
331 | 331 | # issue can be moved to any tracker |
|
332 | 332 | @trackers = Tracker.find(:all) |
|
333 | 333 | if request.post? and params[:new_project_id] and params[:new_tracker_id] |
|
334 | 334 | new_project = Project.find(params[:new_project_id]) |
|
335 | 335 | new_tracker = Tracker.find(params[:new_tracker_id]) |
|
336 | 336 | @issues.each { |i| |
|
337 | 337 | # project dependent properties |
|
338 | 338 | unless i.project_id == new_project.id |
|
339 | 339 | i.category = nil |
|
340 | 340 | i.fixed_version = nil |
|
341 | 341 | end |
|
342 | 342 | # move the issue |
|
343 | 343 | i.project = new_project |
|
344 | 344 | i.tracker = new_tracker |
|
345 | 345 | i.save |
|
346 | 346 | } |
|
347 | 347 | flash[:notice] = l(:notice_successful_update) |
|
348 | 348 | redirect_to :action => 'list_issues', :id => @project |
|
349 | 349 | end |
|
350 | 350 | end |
|
351 | 351 | |
|
352 | 352 | def add_query |
|
353 | 353 | @query = Query.new(params[:query]) |
|
354 | 354 | @query.project = @project |
|
355 | 355 | @query.user = logged_in_user |
|
356 | 356 | |
|
357 | 357 | params[:fields].each do |field| |
|
358 | 358 | @query.add_filter(field, params[:operators][field], params[:values][field]) |
|
359 | 359 | end if params[:fields] |
|
360 | 360 | |
|
361 | 361 | if request.post? and @query.save |
|
362 | 362 | flash[:notice] = l(:notice_successful_create) |
|
363 | 363 | redirect_to :controller => 'reports', :action => 'issue_report', :id => @project |
|
364 | 364 | end |
|
365 | 365 | render :layout => false if request.xhr? |
|
366 | 366 | end |
|
367 | 367 | |
|
368 | 368 | # Add a news to @project |
|
369 | 369 | def add_news |
|
370 | 370 | @news = News.new(:project => @project) |
|
371 | 371 | if request.post? |
|
372 | 372 | @news.attributes = params[:news] |
|
373 | 373 | @news.author_id = self.logged_in_user.id if self.logged_in_user |
|
374 | 374 | if @news.save |
|
375 | 375 | flash[:notice] = l(:notice_successful_create) |
|
376 | 376 | redirect_to :action => 'list_news', :id => @project |
|
377 | 377 | end |
|
378 | 378 | end |
|
379 | 379 | end |
|
380 | 380 | |
|
381 | 381 | # Show news list of @project |
|
382 | 382 | def list_news |
|
383 | 383 | @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC" |
|
384 | 384 | render :action => "list_news", :layout => false if request.xhr? |
|
385 | 385 | end |
|
386 | 386 | |
|
387 | 387 | def add_file |
|
388 | 388 | if request.post? |
|
389 | 389 | @version = @project.versions.find_by_id(params[:version_id]) |
|
390 | 390 | # Save the attachments |
|
391 | 391 | @attachments = [] |
|
392 | 392 | params[:attachments].each { |file| |
|
393 | 393 | next unless file.size > 0 |
|
394 | 394 | a = Attachment.create(:container => @version, :file => file, :author => logged_in_user) |
|
395 | 395 | @attachments << a unless a.new_record? |
|
396 | 396 | } if params[:attachments] and params[:attachments].is_a? Array |
|
397 | 397 | Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? |
|
398 | 398 | redirect_to :controller => 'projects', :action => 'list_files', :id => @project |
|
399 | 399 | end |
|
400 | 400 | @versions = @project.versions |
|
401 | 401 | end |
|
402 | 402 | |
|
403 | 403 | def list_files |
|
404 | 404 | @versions = @project.versions |
|
405 | 405 | end |
|
406 | 406 | |
|
407 | 407 | # Show changelog for @project |
|
408 | 408 | def changelog |
|
409 | 409 | @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position') |
|
410 | 410 | if request.get? |
|
411 | 411 | @selected_tracker_ids = @trackers.collect {|t| t.id.to_s } |
|
412 | 412 | else |
|
413 | 413 | @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array |
|
414 | 414 | end |
|
415 | 415 | @selected_tracker_ids ||= [] |
|
416 | 416 | @fixed_issues = @project.issues.find(:all, |
|
417 | 417 | :include => [ :fixed_version, :status, :tracker ], |
|
418 | 418 | :conditions => [ "issue_statuses.is_closed=? and issues.tracker_id in (#{@selected_tracker_ids.join(',')}) and issues.fixed_version_id is not null", true], |
|
419 | 419 | :order => "versions.effective_date DESC, issues.id DESC" |
|
420 | 420 | ) unless @selected_tracker_ids.empty? |
|
421 | 421 | @fixed_issues ||= [] |
|
422 | 422 | end |
|
423 | 423 | |
|
424 | 424 | def roadmap |
|
425 | 425 | @trackers = Tracker.find(:all, :conditions => ["is_in_roadmap=?", true], :order => 'position') |
|
426 | 426 | if request.get? |
|
427 | 427 | @selected_tracker_ids = @trackers.collect {|t| t.id.to_s } |
|
428 | 428 | else |
|
429 | 429 | @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array |
|
430 | 430 | end |
|
431 | 431 | @selected_tracker_ids ||= [] |
|
432 | 432 | @versions = @project.versions.find(:all, |
|
433 | 433 | :conditions => [ "versions.effective_date>?", Date.today], |
|
434 | 434 | :order => "versions.effective_date ASC" |
|
435 | 435 | ) |
|
436 | 436 | end |
|
437 | 437 | |
|
438 | 438 | def activity |
|
439 | 439 | if params[:year] and params[:year].to_i > 1900 |
|
440 | 440 | @year = params[:year].to_i |
|
441 | 441 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 |
|
442 | 442 | @month = params[:month].to_i |
|
443 | 443 | end |
|
444 | 444 | end |
|
445 | 445 | @year ||= Date.today.year |
|
446 | 446 | @month ||= Date.today.month |
|
447 | 447 | |
|
448 | 448 | @date_from = Date.civil(@year, @month, 1) |
|
449 | 449 | @date_to = (@date_from >> 1)-1 |
|
450 | 450 | |
|
451 | 451 | @events_by_day = {} |
|
452 | 452 | |
|
453 | 453 | unless params[:show_issues] == "0" |
|
454 | 454 | @project.issues.find(:all, :include => [:author, :status], :conditions => ["issues.created_on>=? and issues.created_on<=?", @date_from, @date_to] ).each { |i| |
|
455 | 455 | @events_by_day[i.created_on.to_date] ||= [] |
|
456 | 456 | @events_by_day[i.created_on.to_date] << i |
|
457 | 457 | } |
|
458 | 458 | @show_issues = 1 |
|
459 | 459 | end |
|
460 | 460 | |
|
461 | 461 | unless params[:show_news] == "0" |
|
462 | 462 | @project.news.find(:all, :conditions => ["news.created_on>=? and news.created_on<=?", @date_from, @date_to], :include => :author ).each { |i| |
|
463 | 463 | @events_by_day[i.created_on.to_date] ||= [] |
|
464 | 464 | @events_by_day[i.created_on.to_date] << i |
|
465 | 465 | } |
|
466 | 466 | @show_news = 1 |
|
467 | 467 | end |
|
468 | 468 | |
|
469 | 469 | unless params[:show_files] == "0" |
|
470 | 470 | 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| |
|
471 | 471 | @events_by_day[i.created_on.to_date] ||= [] |
|
472 | 472 | @events_by_day[i.created_on.to_date] << i |
|
473 | 473 | } |
|
474 | 474 | @show_files = 1 |
|
475 | 475 | end |
|
476 | 476 | |
|
477 | 477 | unless params[:show_documents] == "0" |
|
478 | 478 | @project.documents.find(:all, :conditions => ["documents.created_on>=? and documents.created_on<=?", @date_from, @date_to] ).each { |i| |
|
479 | 479 | @events_by_day[i.created_on.to_date] ||= [] |
|
480 | 480 | @events_by_day[i.created_on.to_date] << i |
|
481 | 481 | } |
|
482 | 482 | 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| |
|
483 | 483 | @events_by_day[i.created_on.to_date] ||= [] |
|
484 | 484 | @events_by_day[i.created_on.to_date] << i |
|
485 | 485 | } |
|
486 | 486 | @show_documents = 1 |
|
487 | 487 | end |
|
488 | 488 | |
|
489 | 489 | render :layout => false if request.xhr? |
|
490 | 490 | end |
|
491 | 491 | |
|
492 | 492 | def calendar |
|
493 | 493 | if params[:year] and params[:year].to_i > 1900 |
|
494 | 494 | @year = params[:year].to_i |
|
495 | 495 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 |
|
496 | 496 | @month = params[:month].to_i |
|
497 | 497 | end |
|
498 | 498 | end |
|
499 | 499 | @year ||= Date.today.year |
|
500 | 500 | @month ||= Date.today.month |
|
501 | 501 | |
|
502 | 502 | @date_from = Date.civil(@year, @month, 1) |
|
503 | 503 | @date_to = (@date_from >> 1)-1 |
|
504 | 504 | # start on monday |
|
505 | 505 | @date_from = @date_from - (@date_from.cwday-1) |
|
506 | 506 | # finish on sunday |
|
507 | 507 | @date_to = @date_to + (7-@date_to.cwday) |
|
508 | 508 | |
|
509 | 509 | @issues = @project.issues.find(:all, :include => [:tracker, :status, :assigned_to, :priority], :conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?))", @date_from, @date_to, @date_from, @date_to]) |
|
510 | 510 | render :layout => false if request.xhr? |
|
511 | 511 | end |
|
512 | 512 | |
|
513 | 513 | def gantt |
|
514 | 514 | if params[:year] and params[:year].to_i >0 |
|
515 | 515 | @year_from = params[:year].to_i |
|
516 | 516 | if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12 |
|
517 | 517 | @month_from = params[:month].to_i |
|
518 | 518 | else |
|
519 | 519 | @month_from = 1 |
|
520 | 520 | end |
|
521 | 521 | else |
|
522 | 522 | @month_from ||= (Date.today << 1).month |
|
523 | 523 | @year_from ||= (Date.today << 1).year |
|
524 | 524 | end |
|
525 | 525 | |
|
526 | 526 | @zoom = (params[:zoom].to_i > 0 and params[:zoom].to_i < 5) ? params[:zoom].to_i : 2 |
|
527 | 527 | @months = (params[:months].to_i > 0 and params[:months].to_i < 25) ? params[:months].to_i : 6 |
|
528 | 528 | |
|
529 | 529 | @date_from = Date.civil(@year_from, @month_from, 1) |
|
530 | 530 | @date_to = (@date_from >> @months) - 1 |
|
531 | 531 | @issues = @project.issues.find(:all, :order => "start_date, due_date", :include => [:tracker, :status, :assigned_to, :priority], :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]) |
|
532 | 532 | |
|
533 | 533 | if params[:output]=='pdf' |
|
534 | 534 | @options_for_rfpdf ||= {} |
|
535 | 535 | @options_for_rfpdf[:file_name] = "gantt.pdf" |
|
536 | 536 | render :template => "projects/gantt.rfpdf", :layout => false |
|
537 | 537 | else |
|
538 | 538 | render :template => "projects/gantt.rhtml" |
|
539 | 539 | end |
|
540 | 540 | end |
|
541 | 541 | |
|
542 | 542 | def search |
|
543 | 543 | @token = params[:token] |
|
544 | 544 | @scope = params[:scope] || (params[:submit] ? [] : %w(issues news documents) ) |
|
545 | 545 | |
|
546 | 546 | if @token and @token.length > 2 |
|
547 | @token.strip! | |
|
548 | like_token = "%#{@token}%" | |
|
547 | 549 | @results = [] |
|
548 |
@results += @project.issues.find(:all, :include => :author, :conditions => ["issues.subject like ?", |
|
|
549 |
@results += @project.news.find(:all, :conditions => ["news.title like ?", |
|
|
550 |
@results += @project.documents.find(:all, :conditions => ["title like ?", |
|
|
550 | @results += @project.issues.find(:all, :include => :author, :conditions => ["issues.subject like ? or issues.description like ?", like_token, like_token] ) if @scope.include? 'issues' | |
|
551 | @results += @project.news.find(:all, :conditions => ["news.title like ? or news.description like ?", like_token, like_token], :include => :author ) if @scope.include? 'news' | |
|
552 | @results += @project.documents.find(:all, :conditions => ["title like ? or description like ?", like_token, like_token] ) if @scope.include? 'documents' | |
|
551 | 553 | end |
|
552 | 554 | end |
|
553 | 555 | |
|
554 | 556 | private |
|
555 | 557 | # Find project of id params[:id] |
|
556 | 558 | # if not found, redirect to project list |
|
557 | 559 | # Used as a before_filter |
|
558 | 560 | def find_project |
|
559 | 561 | @project = Project.find(params[:id]) |
|
560 | 562 | @html_title = @project.name |
|
561 | 563 | rescue ActiveRecord::RecordNotFound |
|
562 | 564 | render_404 |
|
563 | 565 | end |
|
564 | 566 | |
|
565 | 567 | # Retrieve query from session or build a new query |
|
566 | 568 | def retrieve_query |
|
567 | 569 | if params[:query_id] |
|
568 | 570 | @query = @project.queries.find(params[:query_id]) |
|
569 | 571 | session[:query] = @query |
|
570 | 572 | else |
|
571 | 573 | if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id |
|
572 | 574 | # Give it a name, required to be valid |
|
573 | 575 | @query = Query.new(:name => "_") |
|
574 | 576 | @query.project = @project |
|
575 | 577 | if params[:fields] and params[:fields].is_a? Array |
|
576 | 578 | params[:fields].each do |field| |
|
577 | 579 | @query.add_filter(field, params[:operators][field], params[:values][field]) |
|
578 | 580 | end |
|
579 | 581 | else |
|
580 | 582 | @query.available_filters.keys.each do |field| |
|
581 | 583 | @query.add_short_filter(field, params[field]) if params[field] |
|
582 | 584 | end |
|
583 | 585 | end |
|
584 | 586 | session[:query] = @query |
|
585 | 587 | else |
|
586 | 588 | @query = session[:query] |
|
587 | 589 | end |
|
588 | 590 | end |
|
589 | 591 | end |
|
590 | 592 | end |
@@ -1,19 +1,23 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | module ProjectsHelper |
|
19 | def result_overview(text, token) | |
|
20 | match = excerpt(text, token) | |
|
21 | match ? highlight(match, token) : truncate(text, 150) | |
|
22 | end | |
|
19 | 23 | end |
@@ -1,32 +1,34 | |||
|
1 | 1 | <h2><%= l(:label_search) %></h2> |
|
2 | 2 | |
|
3 | 3 | <div class="box"> |
|
4 | 4 | <% form_tag({:action => 'search', :id => @project}, :method => :get) do %> |
|
5 | 5 | <p><%= text_field_tag 'token', @token, :size => 30 %> |
|
6 | 6 | <%= check_box_tag 'scope[]', 'issues', (@scope.include? 'issues') %> <label><%= l(:label_issue_plural) %></label> |
|
7 | 7 | <%= check_box_tag 'scope[]', 'news', (@scope.include? 'news') %> <label><%= l(:label_news_plural) %></label> |
|
8 | 8 | <%= check_box_tag 'scope[]', 'documents', (@scope.include? 'documents') %> <label><%= l(:label_document_plural) %></label></p> |
|
9 | 9 | <%= submit_tag l(:button_submit), :name => 'submit' %> |
|
10 | 10 | <% end %> |
|
11 | 11 | </div> |
|
12 | 12 | |
|
13 | 13 | <% if @results %> |
|
14 | 14 | <h3><%= lwr(:label_result, @results.length) %></h3> |
|
15 | 15 | <ul> |
|
16 | 16 | <% @results.each do |e| %> |
|
17 | 17 | <li><p> |
|
18 | 18 | <% if e.is_a? Issue %> |
|
19 | 19 | <%= link_to "#{e.tracker.name} ##{e.id}", :controller => 'issues', :action => 'show', :id => e %>: <%= highlight(h(e.subject), @token) %><br /> |
|
20 | <%= result_overview(e.description, @token) %><br /> | |
|
20 | 21 |
|
|
21 | 22 | <% elsif e.is_a? News %> |
|
22 | 23 | <%=l(:label_news)%>: <%= link_to highlight(h(e.title), @token), :controller => 'news', :action => 'show', :id => e %><br /> |
|
23 | <% unless e.summary.empty? %><%=h e.summary %><br /><% end %> | |
|
24 | <%= result_overview(e.description, @token) %><br /> | |
|
24 | 25 |
|
|
25 | 26 | <% elsif e.is_a? Document %> |
|
26 | 27 | <%=l(:label_document)%>: <%= link_to highlight(h(e.title), @token), :controller => 'documents', :action => 'show', :id => e %><br /> |
|
28 | <%= result_overview(e.description, @token) %><br /> | |
|
27 | 29 |
|
|
28 | 30 | <% end %> |
|
29 | 31 | </p></li> |
|
30 | 32 | <% end %> |
|
31 | 33 | </ul> |
|
32 | 34 | <% end %> No newline at end of file |
@@ -1,379 +1,541 | |||
|
1 | 1 | --- |
|
2 | permissions_052: | |
|
3 | action: destroy_comment | |
|
4 | id: 52 | |
|
5 | description: label_comment_delete | |
|
6 | controller: news | |
|
7 | mail_enabled: false | |
|
8 | mail_option: false | |
|
9 | sort: 1133 | |
|
10 | is_public: false | |
|
2 | 11 | permissions_041: |
|
3 | 12 | action: add_file |
|
4 | 13 | id: 41 |
|
5 | 14 | description: button_add |
|
6 | 15 | controller: projects |
|
7 | 16 | mail_enabled: false |
|
8 |
mail_option: |
|
|
17 | mail_option: true | |
|
9 | 18 | sort: 1320 |
|
10 | 19 | is_public: false |
|
11 | 20 | permissions_030: |
|
12 | 21 | action: destroy |
|
13 | 22 | id: 30 |
|
14 | 23 | description: button_delete |
|
15 | 24 | controller: news |
|
16 | 25 | mail_enabled: false |
|
17 | 26 | mail_option: false |
|
18 | 27 | sort: 1122 |
|
19 | 28 | is_public: false |
|
20 | 29 | permissions_019: |
|
21 | 30 | action: download |
|
22 | 31 | id: 19 |
|
23 | 32 | description: button_download |
|
24 | 33 | controller: issues |
|
25 | 34 | mail_enabled: false |
|
26 | 35 | mail_option: false |
|
27 | 36 | sort: 1010 |
|
28 | 37 | is_public: true |
|
29 | 38 | permissions_008: |
|
30 | 39 | action: edit |
|
31 | 40 | id: 8 |
|
32 | 41 | description: button_edit |
|
33 | 42 | controller: members |
|
34 | 43 | mail_enabled: false |
|
35 | 44 | mail_option: false |
|
36 | 45 | sort: 221 |
|
37 | 46 | is_public: false |
|
47 | permissions_053: | |
|
48 | action: add_query | |
|
49 | id: 53 | |
|
50 | description: button_create | |
|
51 | controller: projects | |
|
52 | mail_enabled: false | |
|
53 | mail_option: false | |
|
54 | sort: 600 | |
|
55 | is_public: false | |
|
38 | 56 | permissions_042: |
|
39 | 57 | action: destroy_file |
|
40 | 58 | id: 42 |
|
41 | 59 | description: button_delete |
|
42 | 60 | controller: versions |
|
43 | 61 | mail_enabled: false |
|
44 | 62 | mail_option: false |
|
45 | 63 | sort: 1322 |
|
46 | 64 | is_public: false |
|
47 | 65 | permissions_031: |
|
48 | 66 | action: list_documents |
|
49 | 67 | id: 31 |
|
50 | 68 | description: button_list |
|
51 | 69 | controller: projects |
|
52 | 70 | mail_enabled: false |
|
53 | 71 | mail_option: false |
|
54 | 72 | sort: 1200 |
|
55 | 73 | is_public: true |
|
56 | 74 | permissions_020: |
|
57 | 75 | action: add_issue |
|
58 | 76 | id: 20 |
|
59 | 77 | description: button_add |
|
60 | 78 | controller: projects |
|
61 | 79 | mail_enabled: true |
|
62 | 80 | mail_option: true |
|
63 | 81 | sort: 1050 |
|
64 | 82 | is_public: false |
|
65 | 83 | permissions_009: |
|
66 | 84 | action: destroy |
|
67 | 85 | id: 9 |
|
68 | 86 | description: button_delete |
|
69 | 87 | controller: members |
|
70 | 88 | mail_enabled: false |
|
71 | 89 | mail_option: false |
|
72 | 90 | sort: 222 |
|
73 | 91 | is_public: false |
|
92 | permissions_054: | |
|
93 | action: show | |
|
94 | id: 54 | |
|
95 | description: button_view | |
|
96 | controller: repositories | |
|
97 | mail_enabled: false | |
|
98 | mail_option: false | |
|
99 | sort: 1450 | |
|
100 | is_public: true | |
|
101 | permissions_043: | |
|
102 | action: move_issues | |
|
103 | id: 43 | |
|
104 | description: button_move | |
|
105 | controller: projects | |
|
106 | mail_enabled: false | |
|
107 | mail_option: false | |
|
108 | sort: 1061 | |
|
109 | is_public: false | |
|
74 | 110 | permissions_032: |
|
75 | 111 | action: show |
|
76 | 112 | id: 32 |
|
77 | 113 | description: button_view |
|
78 | 114 | controller: documents |
|
79 | 115 | mail_enabled: false |
|
80 | 116 | mail_option: false |
|
81 | 117 | sort: 1201 |
|
82 | 118 | is_public: true |
|
83 | 119 | permissions_021: |
|
84 | 120 | action: edit |
|
85 | 121 | id: 21 |
|
86 | 122 | description: button_edit |
|
87 | 123 | controller: issues |
|
88 | 124 | mail_enabled: false |
|
89 | 125 | mail_option: false |
|
90 | 126 | sort: 1055 |
|
91 | 127 | is_public: false |
|
92 | 128 | permissions_010: |
|
93 | 129 | action: add_version |
|
94 | 130 | id: 10 |
|
95 | 131 | description: button_add |
|
96 | 132 | controller: projects |
|
97 | 133 | mail_enabled: false |
|
98 | 134 | mail_option: false |
|
99 | 135 | sort: 320 |
|
100 | 136 | is_public: false |
|
137 | permissions_055: | |
|
138 | action: browse | |
|
139 | id: 55 | |
|
140 | description: label_browse | |
|
141 | controller: repositories | |
|
142 | mail_enabled: false | |
|
143 | mail_option: false | |
|
144 | sort: 1460 | |
|
145 | is_public: true | |
|
146 | permissions_044: | |
|
147 | action: add_note | |
|
148 | id: 44 | |
|
149 | description: label_add_note | |
|
150 | controller: issues | |
|
151 | mail_enabled: false | |
|
152 | mail_option: true | |
|
153 | sort: 1057 | |
|
154 | is_public: false | |
|
101 | 155 | permissions_033: |
|
102 | 156 | action: download |
|
103 | 157 | id: 33 |
|
104 | 158 | description: button_download |
|
105 | 159 | controller: documents |
|
106 | 160 | mail_enabled: false |
|
107 | 161 | mail_option: false |
|
108 | 162 | sort: 1202 |
|
109 | 163 | is_public: true |
|
110 | 164 | permissions_022: |
|
111 | 165 | action: change_status |
|
112 | 166 | id: 22 |
|
113 | 167 | description: label_change_status |
|
114 | 168 | controller: issues |
|
115 | 169 | mail_enabled: true |
|
116 | 170 | mail_option: true |
|
117 | 171 | sort: 1060 |
|
118 | 172 | is_public: false |
|
119 | 173 | permissions_011: |
|
120 | 174 | action: edit |
|
121 | 175 | id: 11 |
|
122 | 176 | description: button_edit |
|
123 | 177 | controller: versions |
|
124 | 178 | mail_enabled: false |
|
125 | 179 | mail_option: false |
|
126 | 180 | sort: 321 |
|
127 | 181 | is_public: false |
|
182 | permissions_056: | |
|
183 | action: entry | |
|
184 | id: 56 | |
|
185 | description: entry | |
|
186 | controller: repositories | |
|
187 | mail_enabled: false | |
|
188 | mail_option: false | |
|
189 | sort: 1462 | |
|
190 | is_public: true | |
|
191 | permissions_045: | |
|
192 | action: export_issues_pdf | |
|
193 | id: 45 | |
|
194 | description: label_export_pdf | |
|
195 | controller: projects | |
|
196 | mail_enabled: false | |
|
197 | mail_option: false | |
|
198 | sort: 1002 | |
|
199 | is_public: true | |
|
128 | 200 | permissions_034: |
|
129 | 201 | action: add_document |
|
130 | 202 | id: 34 |
|
131 | 203 | description: button_add |
|
132 | 204 | controller: projects |
|
133 | 205 | mail_enabled: false |
|
134 |
mail_option: |
|
|
206 | mail_option: true | |
|
135 | 207 | sort: 1220 |
|
136 | 208 | is_public: false |
|
137 | 209 | permissions_023: |
|
138 | 210 | action: destroy |
|
139 | 211 | id: 23 |
|
140 | 212 | description: button_delete |
|
141 | 213 | controller: issues |
|
142 | 214 | mail_enabled: false |
|
143 | 215 | mail_option: false |
|
144 | 216 | sort: 1065 |
|
145 | 217 | is_public: false |
|
146 | 218 | permissions_012: |
|
147 | 219 | action: destroy |
|
148 | 220 | id: 12 |
|
149 | 221 | description: button_delete |
|
150 | 222 | controller: versions |
|
151 | 223 | mail_enabled: false |
|
152 | 224 | mail_option: false |
|
153 | 225 | sort: 322 |
|
154 | 226 | is_public: false |
|
155 | 227 | permissions_001: |
|
156 | 228 | action: show |
|
157 | 229 | id: 1 |
|
158 | 230 | description: label_overview |
|
159 | 231 | controller: projects |
|
160 | 232 | mail_enabled: false |
|
161 | 233 | mail_option: false |
|
162 | 234 | sort: 100 |
|
163 | 235 | is_public: true |
|
236 | permissions_057: | |
|
237 | action: revisions | |
|
238 | id: 57 | |
|
239 | description: label_view_revisions | |
|
240 | controller: repositories | |
|
241 | mail_enabled: false | |
|
242 | mail_option: false | |
|
243 | sort: 1470 | |
|
244 | is_public: true | |
|
245 | permissions_046: | |
|
246 | action: export_pdf | |
|
247 | id: 46 | |
|
248 | description: label_export_pdf | |
|
249 | controller: issues | |
|
250 | mail_enabled: false | |
|
251 | mail_option: false | |
|
252 | sort: 1015 | |
|
253 | is_public: true | |
|
164 | 254 | permissions_035: |
|
165 | 255 | action: edit |
|
166 | 256 | id: 35 |
|
167 | 257 | description: button_edit |
|
168 | 258 | controller: documents |
|
169 | 259 | mail_enabled: false |
|
170 | 260 | mail_option: false |
|
171 | 261 | sort: 1221 |
|
172 | 262 | is_public: false |
|
173 | 263 | permissions_024: |
|
174 | 264 | action: add_attachment |
|
175 | 265 | id: 24 |
|
176 | 266 | description: label_attachment_new |
|
177 | 267 | controller: issues |
|
178 | 268 | mail_enabled: false |
|
179 |
mail_option: |
|
|
269 | mail_option: true | |
|
180 | 270 | sort: 1070 |
|
181 | 271 | is_public: false |
|
182 | 272 | permissions_013: |
|
183 | 273 | action: add_issue_category |
|
184 | 274 | id: 13 |
|
185 | 275 | description: button_add |
|
186 | 276 | controller: projects |
|
187 | 277 | mail_enabled: false |
|
188 | 278 | mail_option: false |
|
189 | 279 | sort: 420 |
|
190 | 280 | is_public: false |
|
191 | 281 | permissions_002: |
|
192 | 282 | action: changelog |
|
193 | 283 | id: 2 |
|
194 | 284 | description: label_change_log |
|
195 | 285 | controller: projects |
|
196 | 286 | mail_enabled: false |
|
197 | 287 | mail_option: false |
|
198 | 288 | sort: 105 |
|
199 | 289 | is_public: true |
|
290 | permissions_058: | |
|
291 | action: revision | |
|
292 | id: 58 | |
|
293 | description: label_view_revisions | |
|
294 | controller: repositories | |
|
295 | mail_enabled: false | |
|
296 | mail_option: false | |
|
297 | sort: 1472 | |
|
298 | is_public: true | |
|
299 | permissions_047: | |
|
300 | action: activity | |
|
301 | id: 47 | |
|
302 | description: label_activity | |
|
303 | controller: projects | |
|
304 | mail_enabled: false | |
|
305 | mail_option: false | |
|
306 | sort: 160 | |
|
307 | is_public: true | |
|
200 | 308 | permissions_036: |
|
201 | 309 | action: destroy |
|
202 | 310 | id: 36 |
|
203 | 311 | description: button_delete |
|
204 | 312 | controller: documents |
|
205 | 313 | mail_enabled: false |
|
206 | 314 | mail_option: false |
|
207 | 315 | sort: 1222 |
|
208 | 316 | is_public: false |
|
209 | 317 | permissions_025: |
|
210 | 318 | action: destroy_attachment |
|
211 | 319 | id: 25 |
|
212 | 320 | description: label_attachment_delete |
|
213 | 321 | controller: issues |
|
214 | 322 | mail_enabled: false |
|
215 | 323 | mail_option: false |
|
216 | 324 | sort: 1075 |
|
217 | 325 | is_public: false |
|
218 | 326 | permissions_014: |
|
219 | 327 | action: edit |
|
220 | 328 | id: 14 |
|
221 | 329 | description: button_edit |
|
222 | 330 | controller: issue_categories |
|
223 | 331 | mail_enabled: false |
|
224 | 332 | mail_option: false |
|
225 | 333 | sort: 421 |
|
226 | 334 | is_public: false |
|
227 | 335 | permissions_003: |
|
228 | 336 | action: issue_report |
|
229 | 337 | id: 3 |
|
230 | 338 | description: label_report_plural |
|
231 | 339 | controller: reports |
|
232 | 340 | mail_enabled: false |
|
233 | 341 | mail_option: false |
|
234 | 342 | sort: 110 |
|
235 | 343 | is_public: true |
|
344 | permissions_059: | |
|
345 | action: diff | |
|
346 | id: 59 | |
|
347 | description: diff | |
|
348 | controller: repositories | |
|
349 | mail_enabled: false | |
|
350 | mail_option: false | |
|
351 | sort: 1480 | |
|
352 | is_public: true | |
|
353 | permissions_048: | |
|
354 | action: calendar | |
|
355 | id: 48 | |
|
356 | description: label_calendar | |
|
357 | controller: projects | |
|
358 | mail_enabled: false | |
|
359 | mail_option: false | |
|
360 | sort: 165 | |
|
361 | is_public: true | |
|
236 | 362 | permissions_037: |
|
237 | 363 | action: add_attachment |
|
238 | 364 | id: 37 |
|
239 | 365 | description: label_attachment_new |
|
240 | 366 | controller: documents |
|
241 | 367 | mail_enabled: false |
|
242 |
mail_option: |
|
|
368 | mail_option: true | |
|
243 | 369 | sort: 1223 |
|
244 | 370 | is_public: false |
|
245 | 371 | permissions_026: |
|
246 | 372 | action: list_news |
|
247 | 373 | id: 26 |
|
248 | 374 | description: button_list |
|
249 | 375 | controller: projects |
|
250 | 376 | mail_enabled: false |
|
251 | 377 | mail_option: false |
|
252 | 378 | sort: 1100 |
|
253 | 379 | is_public: true |
|
254 | 380 | permissions_015: |
|
255 | 381 | action: destroy |
|
256 | 382 | id: 15 |
|
257 | 383 | description: button_delete |
|
258 | 384 | controller: issue_categories |
|
259 | 385 | mail_enabled: false |
|
260 | 386 | mail_option: false |
|
261 | 387 | sort: 422 |
|
262 | 388 | is_public: false |
|
263 | 389 | permissions_004: |
|
264 | 390 | action: settings |
|
265 | 391 | id: 4 |
|
266 | 392 | description: label_settings |
|
267 | 393 | controller: projects |
|
268 | 394 | mail_enabled: false |
|
269 | 395 | mail_option: false |
|
270 | 396 | sort: 150 |
|
271 | 397 | is_public: false |
|
398 | permissions_060: | |
|
399 | action: search | |
|
400 | id: 61 | |
|
401 | description: label_search | |
|
402 | controller: projects | |
|
403 | mail_enabled: false | |
|
404 | mail_option: false | |
|
405 | sort: 130 | |
|
406 | is_public: true | |
|
407 | permissions_049: | |
|
408 | action: gantt | |
|
409 | id: 49 | |
|
410 | description: label_gantt | |
|
411 | controller: projects | |
|
412 | mail_enabled: false | |
|
413 | mail_option: false | |
|
414 | sort: 166 | |
|
415 | is_public: true | |
|
272 | 416 | permissions_038: |
|
273 | 417 | action: destroy_attachment |
|
274 | 418 | id: 38 |
|
275 | 419 | description: label_attachment_delete |
|
276 | 420 | controller: documents |
|
277 | 421 | mail_enabled: false |
|
278 | 422 | mail_option: false |
|
279 | 423 | sort: 1224 |
|
280 | 424 | is_public: false |
|
281 | 425 | permissions_027: |
|
282 | 426 | action: show |
|
283 | 427 | id: 27 |
|
284 | 428 | description: button_view |
|
285 | 429 | controller: news |
|
286 | 430 | mail_enabled: false |
|
287 | 431 | mail_option: false |
|
288 | 432 | sort: 1101 |
|
289 | 433 | is_public: true |
|
290 | 434 | permissions_016: |
|
291 | 435 | action: list_issues |
|
292 | 436 | id: 16 |
|
293 | 437 | description: button_list |
|
294 | 438 | controller: projects |
|
295 | 439 | mail_enabled: false |
|
296 | 440 | mail_option: false |
|
297 | 441 | sort: 1000 |
|
298 | 442 | is_public: true |
|
299 | 443 | permissions_005: |
|
300 | 444 | action: edit |
|
301 | 445 | id: 5 |
|
302 | 446 | description: button_edit |
|
303 | 447 | controller: projects |
|
304 | 448 | mail_enabled: false |
|
305 | 449 | mail_option: false |
|
306 | 450 | sort: 151 |
|
307 | 451 | is_public: false |
|
452 | permissions_050: | |
|
453 | action: history | |
|
454 | id: 50 | |
|
455 | description: label_history | |
|
456 | controller: issues | |
|
457 | mail_enabled: false | |
|
458 | mail_option: false | |
|
459 | sort: 1006 | |
|
460 | is_public: true | |
|
308 | 461 | permissions_039: |
|
309 | 462 | action: list_files |
|
310 | 463 | id: 39 |
|
311 | 464 | description: button_list |
|
312 | 465 | controller: projects |
|
313 | 466 | mail_enabled: false |
|
314 | 467 | mail_option: false |
|
315 | 468 | sort: 1300 |
|
316 | 469 | is_public: true |
|
317 | 470 | permissions_028: |
|
318 | 471 | action: add_news |
|
319 | 472 | id: 28 |
|
320 | 473 | description: button_add |
|
321 | 474 | controller: projects |
|
322 | 475 | mail_enabled: false |
|
323 | 476 | mail_option: false |
|
324 | 477 | sort: 1120 |
|
325 | 478 | is_public: false |
|
326 | 479 | permissions_017: |
|
327 | 480 | action: export_issues_csv |
|
328 | 481 | id: 17 |
|
329 | 482 | description: label_export_csv |
|
330 | 483 | controller: projects |
|
331 | 484 | mail_enabled: false |
|
332 | 485 | mail_option: false |
|
333 | 486 | sort: 1001 |
|
334 | 487 | is_public: true |
|
335 | 488 | permissions_006: |
|
336 | 489 | action: list_members |
|
337 | 490 | id: 6 |
|
338 | 491 | description: button_list |
|
339 | 492 | controller: projects |
|
340 | 493 | mail_enabled: false |
|
341 | 494 | mail_option: false |
|
342 | 495 | sort: 200 |
|
343 | 496 | is_public: true |
|
497 | permissions_051: | |
|
498 | action: add_comment | |
|
499 | id: 51 | |
|
500 | description: label_comment_add | |
|
501 | controller: news | |
|
502 | mail_enabled: false | |
|
503 | mail_option: false | |
|
504 | sort: 1130 | |
|
505 | is_public: false | |
|
344 | 506 | permissions_040: |
|
345 | 507 | action: download |
|
346 | 508 | id: 40 |
|
347 | 509 | description: button_download |
|
348 | 510 | controller: versions |
|
349 | 511 | mail_enabled: false |
|
350 | 512 | mail_option: false |
|
351 | 513 | sort: 1301 |
|
352 | 514 | is_public: true |
|
353 | 515 | permissions_029: |
|
354 | 516 | action: edit |
|
355 | 517 | id: 29 |
|
356 | 518 | description: button_edit |
|
357 | 519 | controller: news |
|
358 | 520 | mail_enabled: false |
|
359 | 521 | mail_option: false |
|
360 | 522 | sort: 1121 |
|
361 | 523 | is_public: false |
|
362 | 524 | permissions_018: |
|
363 | 525 | action: show |
|
364 | 526 | id: 18 |
|
365 | 527 | description: button_view |
|
366 | 528 | controller: issues |
|
367 | 529 | mail_enabled: false |
|
368 | 530 | mail_option: false |
|
369 | 531 | sort: 1005 |
|
370 | 532 | is_public: true |
|
371 | 533 | permissions_007: |
|
372 | 534 | action: add_member |
|
373 | 535 | id: 7 |
|
374 | 536 | description: button_add |
|
375 | 537 | controller: projects |
|
376 | 538 | mail_enabled: false |
|
377 | 539 | mail_option: false |
|
378 | 540 | sort: 220 |
|
379 | 541 | is_public: false |
@@ -1,114 +1,124 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.dirname(__FILE__) + '/../test_helper' |
|
19 | 19 | require 'projects_controller' |
|
20 | 20 | |
|
21 | 21 | # Re-raise errors caught by the controller. |
|
22 | 22 | class ProjectsController; def rescue_action(e) raise e end; end |
|
23 | 23 | |
|
24 | 24 | class ProjectsControllerTest < Test::Unit::TestCase |
|
25 | 25 | fixtures :projects, :permissions |
|
26 | 26 | |
|
27 | 27 | def setup |
|
28 | 28 | @controller = ProjectsController.new |
|
29 | 29 | @request = ActionController::TestRequest.new |
|
30 | 30 | @response = ActionController::TestResponse.new |
|
31 | 31 | end |
|
32 | 32 | |
|
33 | 33 | def test_index |
|
34 | 34 | get :index |
|
35 | 35 | assert_response :success |
|
36 | 36 | assert_template 'list' |
|
37 | 37 | end |
|
38 | 38 | |
|
39 | 39 | def test_list |
|
40 | 40 | get :list |
|
41 | 41 | assert_response :success |
|
42 | 42 | assert_template 'list' |
|
43 | 43 | assert_not_nil assigns(:projects) |
|
44 | 44 | end |
|
45 | 45 | |
|
46 | 46 | def test_show |
|
47 | 47 | get :show, :id => 1 |
|
48 | 48 | assert_response :success |
|
49 | 49 | assert_template 'show' |
|
50 | 50 | assert_not_nil assigns(:project) |
|
51 | 51 | end |
|
52 | 52 | |
|
53 | 53 | def test_list_members |
|
54 | 54 | get :list_members, :id => 1 |
|
55 | 55 | assert_response :success |
|
56 | 56 | assert_template 'list_members' |
|
57 | 57 | assert_not_nil assigns(:members) |
|
58 | 58 | end |
|
59 | 59 | |
|
60 | 60 | def test_list_documents |
|
61 | 61 | get :list_documents, :id => 1 |
|
62 | 62 | assert_response :success |
|
63 | 63 | assert_template 'list_documents' |
|
64 | 64 | assert_not_nil assigns(:documents) |
|
65 | 65 | end |
|
66 | 66 | |
|
67 | 67 | def test_list_issues |
|
68 | 68 | get :list_issues, :id => 1 |
|
69 | 69 | assert_response :success |
|
70 | 70 | assert_template 'list_issues' |
|
71 | 71 | assert_not_nil assigns(:issues) |
|
72 | 72 | end |
|
73 | 73 | |
|
74 | 74 | def test_list_issues_with_filter |
|
75 | 75 | get :list_issues, :id => 1, :set_filter => 1 |
|
76 | 76 | assert_response :success |
|
77 | 77 | assert_template 'list_issues' |
|
78 | 78 | assert_not_nil assigns(:issues) |
|
79 | 79 | end |
|
80 | 80 | |
|
81 | 81 | def test_list_issues_reset_filter |
|
82 | 82 | post :list_issues, :id => 1 |
|
83 | 83 | assert_response :success |
|
84 | 84 | assert_template 'list_issues' |
|
85 | 85 | assert_not_nil assigns(:issues) |
|
86 | 86 | end |
|
87 | 87 | |
|
88 | 88 | def test_export_issues_csv |
|
89 | 89 | get :export_issues_csv, :id => 1 |
|
90 | 90 | assert_response :success |
|
91 | 91 | assert_not_nil assigns(:issues) |
|
92 | 92 | end |
|
93 | 93 | |
|
94 | 94 | def test_list_news |
|
95 | 95 | get :list_news, :id => 1 |
|
96 | 96 | assert_response :success |
|
97 | 97 | assert_template 'list_news' |
|
98 | 98 | assert_not_nil assigns(:news) |
|
99 | 99 | end |
|
100 | 100 | |
|
101 | 101 | def test_list_files |
|
102 | 102 | get :list_files, :id => 1 |
|
103 | 103 | assert_response :success |
|
104 | 104 | assert_template 'list_files' |
|
105 | 105 | assert_not_nil assigns(:versions) |
|
106 | 106 | end |
|
107 | 107 | |
|
108 | 108 | def test_changelog |
|
109 | 109 | get :changelog, :id => 1 |
|
110 | 110 | assert_response :success |
|
111 | 111 | assert_template 'changelog' |
|
112 | 112 | assert_not_nil assigns(:fixed_issues) |
|
113 | 113 | end |
|
114 | ||
|
115 | def test_search | |
|
116 | get :search, :id => 1 | |
|
117 | assert_response :success | |
|
118 | assert_template 'search' | |
|
119 | ||
|
120 | get :search, :id => 1, :token => "can", :scope => ["issues", "news", "documents"] | |
|
121 | assert_response :success | |
|
122 | assert_template 'search' | |
|
123 | end | |
|
114 | 124 | end |
General Comments 0
You need to be logged in to leave comments.
Login now