##// END OF EJS Templates
tracker filter added on change log...
Jean-Philippe Lang -
r16:6b08e1b3155e
parent child
Show More
@@ -1,296 +1,305
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 class ProjectsController < ApplicationController
19 19 layout 'base'
20 20 before_filter :find_project, :authorize, :except => [ :index, :list, :add ]
21 21 before_filter :require_admin, :only => [ :add, :destroy ]
22 22
23 23 helper :sort
24 24 include SortHelper
25 25 helper :search_filter
26 26 include SearchFilterHelper
27 27 helper :custom_fields
28 28 include CustomFieldsHelper
29 29
30 30 def index
31 31 list
32 32 render :action => 'list'
33 33 end
34 34
35 35 # Lists public projects
36 36 def list
37 37 sort_init 'name', 'asc'
38 38 sort_update
39 39 @project_count = Project.count(["is_public=?", true])
40 40 @project_pages = Paginator.new self, @project_count,
41 41 15,
42 42 @params['page']
43 43 @projects = Project.find :all, :order => sort_clause,
44 44 :conditions => ["is_public=?", true],
45 45 :limit => @project_pages.items_per_page,
46 46 :offset => @project_pages.current.offset
47 47 end
48 48
49 49 # Add a new project
50 50 def add
51 51 @custom_fields = IssueCustomField.find(:all)
52 52 @root_projects = Project.find(:all, :conditions => "parent_id is null")
53 53 @project = Project.new(params[:project])
54 54 if request.get?
55 55 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
56 56 else
57 57 @project.custom_fields = CustomField.find(@params[:custom_field_ids]) if @params[:custom_field_ids]
58 58 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
59 59 @project.custom_values = @custom_values
60 60 if @project.save
61 61 flash[:notice] = l(:notice_successful_create)
62 62 redirect_to :controller => 'admin', :action => 'projects'
63 63 end
64 64 end
65 65 end
66 66
67 67 # Show @project
68 68 def show
69 69 @custom_values = @project.custom_values.find(:all, :include => :custom_field)
70 70 @members = @project.members.find(:all, :include => [:user, :role])
71 71 @subprojects = @project.children if @project.children_count > 0
72 72 @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC")
73 73 @trackers = Tracker.find(:all)
74 74 end
75 75
76 76 def settings
77 77 @root_projects = Project::find(:all, :conditions => ["parent_id is null and id <> ?", @project.id])
78 78 @custom_fields = IssueCustomField::find_all
79 79 @issue_category ||= IssueCategory.new
80 80 @member ||= @project.members.new
81 81 @roles = Role.find_all
82 82 @users = User.find_all - @project.members.find(:all, :include => :user).collect{|m| m.user }
83 83 @custom_values = ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
84 84 end
85 85
86 86 # Edit @project
87 87 def edit
88 88 if request.post?
89 89 @project.custom_fields = IssueCustomField.find(@params[:custom_field_ids]) if @params[:custom_field_ids]
90 90 if params[:custom_fields]
91 91 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
92 92 @project.custom_values = @custom_values
93 93 end
94 94 if @project.update_attributes(params[:project])
95 95 flash[:notice] = l(:notice_successful_update)
96 96 redirect_to :action => 'settings', :id => @project
97 97 else
98 98 settings
99 99 render :action => 'settings'
100 100 end
101 101 end
102 102 end
103 103
104 104 # Delete @project
105 105 def destroy
106 106 if request.post? and params[:confirm]
107 107 @project.destroy
108 108 redirect_to :controller => 'admin', :action => 'projects'
109 109 end
110 110 end
111 111
112 112 # Add a new issue category to @project
113 113 def add_issue_category
114 114 if request.post?
115 115 @issue_category = @project.issue_categories.build(params[:issue_category])
116 116 if @issue_category.save
117 117 flash[:notice] = l(:notice_successful_create)
118 118 redirect_to :action => 'settings', :id => @project
119 119 else
120 120 settings
121 121 render :action => 'settings'
122 122 end
123 123 end
124 124 end
125 125
126 126 # Add a new version to @project
127 127 def add_version
128 128 @version = @project.versions.build(params[:version])
129 129 if request.post? and @version.save
130 130 flash[:notice] = l(:notice_successful_create)
131 131 redirect_to :action => 'settings', :id => @project
132 132 end
133 133 end
134 134
135 135 # Add a new member to @project
136 136 def add_member
137 137 @member = @project.members.build(params[:member])
138 138 if request.post?
139 139 if @member.save
140 140 flash[:notice] = l(:notice_successful_create)
141 141 redirect_to :action => 'settings', :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 # Show members list of @project
150 150 def list_members
151 151 @members = @project.members
152 152 end
153 153
154 154 # Add a new document to @project
155 155 def add_document
156 156 @categories = Enumeration::get_values('DCAT')
157 157 @document = @project.documents.build(params[:document])
158 158 if request.post?
159 159 # Save the attachment
160 160 if params[:attachment][:file].size > 0
161 161 @attachment = @document.attachments.build(params[:attachment])
162 162 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
163 163 end
164 164 if @document.save
165 165 flash[:notice] = l(:notice_successful_create)
166 166 redirect_to :action => 'list_documents', :id => @project
167 167 end
168 168 end
169 169 end
170 170
171 171 # Show documents list of @project
172 172 def list_documents
173 173 @documents = @project.documents
174 174 end
175 175
176 176 # Add a new issue to @project
177 177 def add_issue
178 178 @tracker = Tracker.find(params[:tracker_id])
179 179 @priorities = Enumeration::get_values('IPRI')
180 180 @issue = Issue.new(:project => @project, :tracker => @tracker)
181 181 if request.get?
182 182 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
183 183 else
184 184 @issue.attributes = params[:issue]
185 185 @issue.author_id = self.logged_in_user.id if self.logged_in_user
186 186 # Create the document if a file was sent
187 187 if params[:attachment][:file].size > 0
188 188 @attachment = @issue.attachments.build(params[:attachment])
189 189 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
190 190 end
191 191 @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]) }
192 192 @issue.custom_values = @custom_values
193 193 if @issue.save
194 194 flash[:notice] = l(:notice_successful_create)
195 195 Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled?
196 196 redirect_to :action => 'list_issues', :id => @project
197 197 end
198 198 end
199 199 end
200 200
201 201 # Show filtered/sorted issues list of @project
202 202 def list_issues
203 203 sort_init 'issues.id', 'desc'
204 204 sort_update
205 205
206 206 search_filter_init_list_issues
207 207 search_filter_update if params[:set_filter] or request.post?
208 208
209 209 @issue_count = Issue.count(:include => [:status, :project], :conditions => search_filter_clause)
210 210 @issue_pages = Paginator.new self, @issue_count, 15, @params['page']
211 211 @issues = Issue.find :all, :order => sort_clause,
212 212 :include => [ :author, :status, :tracker, :project ],
213 213 :conditions => search_filter_clause,
214 214 :limit => @issue_pages.items_per_page,
215 215 :offset => @issue_pages.current.offset
216 216 end
217 217
218 218 # Export filtered/sorted issues list to CSV
219 219 def export_issues_csv
220 220 sort_init 'issues.id', 'desc'
221 221 sort_update
222 222
223 223 search_filter_init_list_issues
224 224
225 225 @issues = Issue.find :all, :order => sort_clause,
226 226 :include => [ :author, :status, :tracker, :project ],
227 227 :conditions => search_filter_clause
228 228
229 229 export = StringIO.new
230 230 CSV::Writer.generate(export, ',') do |csv|
231 231 csv << %w(Id Status Tracker Subject Author Created Updated)
232 232 @issues.each do |issue|
233 233 csv << [issue.id, issue.status.name, issue.tracker.name, issue.subject, issue.author.display_name, l_datetime(issue.created_on), l_datetime(issue.updated_on)]
234 234 end
235 235 end
236 236 export.rewind
237 237 send_data(export.read,
238 238 :type => 'text/csv; charset=utf-8; header=present',
239 239 :filename => 'export.csv')
240 240 end
241 241
242 242 # Add a news to @project
243 243 def add_news
244 244 @news = News.new(:project => @project)
245 245 if request.post?
246 246 @news.attributes = params[:news]
247 247 @news.author_id = self.logged_in_user.id if self.logged_in_user
248 248 if @news.save
249 249 flash[:notice] = l(:notice_successful_create)
250 250 redirect_to :action => 'list_news', :id => @project
251 251 end
252 252 end
253 253 end
254 254
255 255 # Show news list of @project
256 256 def list_news
257 257 @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC"
258 258 end
259 259
260 260 def add_file
261 261 if request.post?
262 262 # Save the attachment
263 263 if params[:attachment][:file].size > 0
264 264 @attachment = @project.versions.find(params[:version_id]).attachments.build(params[:attachment])
265 265 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
266 266 if @attachment.save
267 267 flash[:notice] = l(:notice_successful_create)
268 268 redirect_to :controller => 'projects', :action => 'list_files', :id => @project
269 269 end
270 270 end
271 271 end
272 272 @versions = @project.versions
273 273 end
274 274
275 275 def list_files
276 276 @versions = @project.versions
277 277 end
278 278
279 # Show changelog of @project
279 # Show changelog for @project
280 280 def changelog
281 @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true])
282 if request.get?
283 @selected_tracker_ids = @trackers.collect {|t| t.id.to_s }
284 else
285 @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array
286 end
287 @selected_tracker_ids ||= []
281 288 @fixed_issues = @project.issues.find(:all,
282 289 :include => [ :fixed_version, :status, :tracker ],
283 :conditions => [ "issue_statuses.is_closed=? and trackers.is_in_chlog=? and issues.fixed_version_id is not null", true, true]
284 )
290 :conditions => [ "issue_statuses.is_closed=? and issues.tracker_id in (#{@selected_tracker_ids.join(',')}) and issues.fixed_version_id is not null", true],
291 :order => "versions.effective_date DESC, issues.id DESC"
292 ) unless @selected_tracker_ids.empty?
293 @fixed_issues ||= []
285 294 end
286 295
287 296 private
288 297 # Find project of id params[:id]
289 298 # if not found, redirect to project list
290 # used as a before_filter
299 # Used as a before_filter
291 300 def find_project
292 301 @project = Project.find(params[:id])
293 302 rescue
294 303 redirect_to :action => 'list'
295 304 end
296 305 end
@@ -1,12 +1,25
1 1 <h2><%=l(:label_change_log)%></h2>
2 2
3 <% fixed_issues = @fixed_issues.group_by {|i| i.fixed_version } %>
4 <% fixed_issues.each do |version, issues| %>
5 <p><strong><%= version.name %></strong> - <%= format_date(version.effective_date) %><br />
6 <%=h version.description %></p>
7 <ul>
8 <% issues.each do |i| %>
9 <li><%= link_to i.long_id, :controller => 'issues', :action => 'show', :id => i %> [<%= i.tracker.name %>]: <%= i.subject %></li>
3
4 <%= start_form_tag %>
5 <% @trackers.each do |tracker| %>
6 <%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
7 <%= tracker.name %>
10 8 <% end %>
11 </ul>
9 &nbsp;&nbsp;<%= submit_tag l(:button_apply), :class => 'button-small' %>
10 <%= end_form_tag %>
11
12 <p>&nbsp;</p>
13
14 <% ver_id = nil
15 @fixed_issues.each do |issue| %>
16 <% unless ver_id == issue.fixed_version_id %>
17 <% if ver_id %></ul><% end %>
18 <p><strong><%= issue.fixed_version.name %></strong> - <%= format_date(issue.fixed_version.effective_date) %><br />
19 <%=h issue.fixed_version.description %></p>
20 <ul>
21 <% ver_id = issue.fixed_version_id
22 end %>
23 <li><%= link_to issue.long_id, :controller => 'issues', :action => 'show', :id => issue %> [<%= issue.tracker.name %>]: <%= issue.subject %></li>
12 24 <% end %>
25
General Comments 0
You need to be logged in to leave comments. Login now