@@ -1,285 +1,285 | |||
|
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 | class ProjectsController < ApplicationController |
|
19 | 19 | menu_item :overview |
|
20 | 20 | menu_item :activity, :only => :activity |
|
21 | 21 | menu_item :roadmap, :only => :roadmap |
|
22 | 22 | menu_item :files, :only => [:list_files, :add_file] |
|
23 | 23 | menu_item :settings, :only => :settings |
|
24 | 24 | menu_item :issues, :only => [:changelog] |
|
25 | 25 | |
|
26 | 26 | before_filter :find_project, :except => [ :index, :list, :add, :activity ] |
|
27 | 27 | before_filter :find_optional_project, :only => :activity |
|
28 | 28 | before_filter :authorize, :except => [ :index, :list, :add, :archive, :unarchive, :destroy, :activity ] |
|
29 | 29 | before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ] |
|
30 | 30 | accept_key_auth :activity |
|
31 | 31 | |
|
32 | 32 | helper :sort |
|
33 | 33 | include SortHelper |
|
34 | 34 | helper :custom_fields |
|
35 | 35 | include CustomFieldsHelper |
|
36 | 36 | helper :ifpdf |
|
37 | 37 | include IfpdfHelper |
|
38 | 38 | helper :issues |
|
39 | 39 | helper IssuesHelper |
|
40 | 40 | helper :queries |
|
41 | 41 | include QueriesHelper |
|
42 | 42 | helper :repositories |
|
43 | 43 | include RepositoriesHelper |
|
44 | 44 | include ProjectsHelper |
|
45 | 45 | |
|
46 | 46 | # Lists visible projects |
|
47 | 47 | def index |
|
48 | 48 | projects = Project.find :all, |
|
49 | 49 | :conditions => Project.visible_by(User.current), |
|
50 | 50 | :include => :parent |
|
51 | 51 | respond_to do |format| |
|
52 | 52 | format.html { |
|
53 | 53 | @project_tree = projects.group_by {|p| p.parent || p} |
|
54 | 54 | @project_tree.keys.each {|p| @project_tree[p] -= [p]} |
|
55 | 55 | } |
|
56 | 56 | format.atom { |
|
57 | 57 | render_feed(projects.sort_by(&:created_on).reverse.slice(0, Setting.feeds_limit.to_i), |
|
58 | 58 | :title => "#{Setting.app_title}: #{l(:label_project_latest)}") |
|
59 | 59 | } |
|
60 | 60 | end |
|
61 | 61 | end |
|
62 | 62 | |
|
63 | 63 | # Add a new project |
|
64 | 64 | def add |
|
65 | 65 | @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") |
|
66 | 66 | @trackers = Tracker.all |
|
67 | 67 | @root_projects = Project.find(:all, |
|
68 | 68 | :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}", |
|
69 | 69 | :order => 'name') |
|
70 | 70 | @project = Project.new(params[:project]) |
|
71 | 71 | if request.get? |
|
72 | 72 | @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers? |
|
73 | 73 | @project.trackers = Tracker.all |
|
74 | 74 | @project.is_public = Setting.default_projects_public? |
|
75 | 75 | @project.enabled_module_names = Redmine::AccessControl.available_project_modules |
|
76 | 76 | else |
|
77 | 77 | @project.enabled_module_names = params[:enabled_modules] |
|
78 | 78 | if @project.save |
|
79 | 79 | flash[:notice] = l(:notice_successful_create) |
|
80 | 80 | redirect_to :controller => 'admin', :action => 'projects' |
|
81 | 81 | end |
|
82 | 82 | end |
|
83 | 83 | end |
|
84 | 84 | |
|
85 | 85 | # Show @project |
|
86 | 86 | def show |
|
87 | 87 | @members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role} |
|
88 | 88 | @subprojects = @project.children.find(:all, :conditions => Project.visible_by(User.current)) |
|
89 | 89 | @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") |
|
90 | 90 | @trackers = @project.rolled_up_trackers |
|
91 | 91 | |
|
92 | 92 | cond = @project.project_condition(Setting.display_subprojects_issues?) |
|
93 | 93 | Issue.visible_by(User.current) do |
|
94 | 94 | @open_issues_by_tracker = Issue.count(:group => :tracker, |
|
95 | 95 | :include => [:project, :status, :tracker], |
|
96 | 96 | :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false]) |
|
97 | 97 | @total_issues_by_tracker = Issue.count(:group => :tracker, |
|
98 | 98 | :include => [:project, :status, :tracker], |
|
99 | 99 | :conditions => cond) |
|
100 | 100 | end |
|
101 | 101 | TimeEntry.visible_by(User.current) do |
|
102 | 102 | @total_hours = TimeEntry.sum(:hours, |
|
103 | 103 | :include => :project, |
|
104 | 104 | :conditions => cond).to_f |
|
105 | 105 | end |
|
106 | 106 | @key = User.current.rss_key |
|
107 | 107 | end |
|
108 | 108 | |
|
109 | 109 | def settings |
|
110 | 110 | @root_projects = Project.find(:all, |
|
111 | 111 | :conditions => ["parent_id IS NULL AND status = #{Project::STATUS_ACTIVE} AND id <> ?", @project.id], |
|
112 | 112 | :order => 'name') |
|
113 | 113 | @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") |
|
114 | 114 | @issue_category ||= IssueCategory.new |
|
115 | 115 | @member ||= @project.members.new |
|
116 | 116 | @trackers = Tracker.all |
|
117 | 117 | @repository ||= @project.repository |
|
118 | 118 | @wiki ||= @project.wiki |
|
119 | 119 | end |
|
120 | 120 | |
|
121 | 121 | # Edit @project |
|
122 | 122 | def edit |
|
123 | 123 | if request.post? |
|
124 | 124 | @project.attributes = params[:project] |
|
125 | 125 | if @project.save |
|
126 | 126 | flash[:notice] = l(:notice_successful_update) |
|
127 | 127 | redirect_to :action => 'settings', :id => @project |
|
128 | 128 | else |
|
129 | 129 | settings |
|
130 | 130 | render :action => 'settings' |
|
131 | 131 | end |
|
132 | 132 | end |
|
133 | 133 | end |
|
134 | 134 | |
|
135 | 135 | def modules |
|
136 | 136 | @project.enabled_module_names = params[:enabled_modules] |
|
137 | 137 | redirect_to :action => 'settings', :id => @project, :tab => 'modules' |
|
138 | 138 | end |
|
139 | 139 | |
|
140 | 140 | def archive |
|
141 | 141 | @project.archive if request.post? && @project.active? |
|
142 | 142 | redirect_to :controller => 'admin', :action => 'projects' |
|
143 | 143 | end |
|
144 | 144 | |
|
145 | 145 | def unarchive |
|
146 | 146 | @project.unarchive if request.post? && !@project.active? |
|
147 | 147 | redirect_to :controller => 'admin', :action => 'projects' |
|
148 | 148 | end |
|
149 | 149 | |
|
150 | 150 | # Delete @project |
|
151 | 151 | def destroy |
|
152 | 152 | @project_to_destroy = @project |
|
153 | 153 | if request.post? and params[:confirm] |
|
154 | 154 | @project_to_destroy.destroy |
|
155 | 155 | redirect_to :controller => 'admin', :action => 'projects' |
|
156 | 156 | end |
|
157 | 157 | # hide project in layout |
|
158 | 158 | @project = nil |
|
159 | 159 | end |
|
160 | 160 | |
|
161 | 161 | # Add a new issue category to @project |
|
162 | 162 | def add_issue_category |
|
163 | 163 | @category = @project.issue_categories.build(params[:category]) |
|
164 | 164 | if request.post? and @category.save |
|
165 | 165 | respond_to do |format| |
|
166 | 166 | format.html do |
|
167 | 167 | flash[:notice] = l(:notice_successful_create) |
|
168 | 168 | redirect_to :action => 'settings', :tab => 'categories', :id => @project |
|
169 | 169 | end |
|
170 | 170 | format.js do |
|
171 | 171 | # IE doesn't support the replace_html rjs method for select box options |
|
172 | 172 | render(:update) {|page| page.replace "issue_category_id", |
|
173 | 173 | content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]') |
|
174 | 174 | } |
|
175 | 175 | end |
|
176 | 176 | end |
|
177 | 177 | end |
|
178 | 178 | end |
|
179 | 179 | |
|
180 | 180 | # Add a new version to @project |
|
181 | 181 | def add_version |
|
182 | 182 | @version = @project.versions.build(params[:version]) |
|
183 | 183 | if request.post? and @version.save |
|
184 | 184 | flash[:notice] = l(:notice_successful_create) |
|
185 | 185 | redirect_to :action => 'settings', :tab => 'versions', :id => @project |
|
186 | 186 | end |
|
187 | 187 | end |
|
188 | 188 | |
|
189 | 189 | def add_file |
|
190 | 190 | if request.post? |
|
191 | 191 | @version = @project.versions.find_by_id(params[:version_id]) |
|
192 | 192 | attachments = attach_files(@version, params[:attachments]) |
|
193 | 193 | Mailer.deliver_attachments_added(attachments) if !attachments.empty? && Setting.notified_events.include?('file_added') |
|
194 | 194 | redirect_to :controller => 'projects', :action => 'list_files', :id => @project |
|
195 | 195 | end |
|
196 | 196 | @versions = @project.versions.sort |
|
197 | 197 | end |
|
198 | 198 | |
|
199 | 199 | def list_files |
|
200 | 200 | sort_init "#{Attachment.table_name}.filename", "asc" |
|
201 | 201 | sort_update |
|
202 | 202 | @versions = @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse |
|
203 | 203 | render :layout => !request.xhr? |
|
204 | 204 | end |
|
205 | 205 | |
|
206 | 206 | # Show changelog for @project |
|
207 | 207 | def changelog |
|
208 | 208 | @trackers = @project.trackers.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position') |
|
209 | 209 | retrieve_selected_tracker_ids(@trackers) |
|
210 | 210 | @versions = @project.versions.sort |
|
211 | 211 | end |
|
212 | 212 | |
|
213 | 213 | def roadmap |
|
214 | 214 | @trackers = @project.trackers.find(:all, :conditions => ["is_in_roadmap=?", true]) |
|
215 | 215 | retrieve_selected_tracker_ids(@trackers) |
|
216 | 216 | @versions = @project.versions.sort |
|
217 | 217 | @versions = @versions.select {|v| !v.completed? } unless params[:completed] |
|
218 | 218 | end |
|
219 | 219 | |
|
220 | 220 | def activity |
|
221 | 221 | @days = Setting.activity_days_default.to_i |
|
222 | 222 | |
|
223 | 223 | if params[:from] |
|
224 | 224 | begin; @date_to = params[:from].to_date + 1; rescue; end |
|
225 | 225 | end |
|
226 | 226 | |
|
227 | 227 | @date_to ||= Date.today + 1 |
|
228 | 228 | @date_from = @date_to - @days |
|
229 | 229 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') |
|
230 |
@author = (params[:user_id] ? User.active.find(params[:user_id]) |
|
|
230 | @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id])) | |
|
231 | 231 | |
|
232 | 232 | @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project, |
|
233 | 233 | :with_subprojects => @with_subprojects, |
|
234 | 234 | :author => @author) |
|
235 | 235 | @activity.scope_select {|t| !params["show_#{t}"].nil?} |
|
236 | 236 | @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty? |
|
237 | 237 | |
|
238 | 238 | events = @activity.events(@date_from, @date_to) |
|
239 | 239 | |
|
240 | 240 | respond_to do |format| |
|
241 | 241 | format.html { |
|
242 | 242 | @events_by_day = events.group_by(&:event_date) |
|
243 | 243 | render :layout => false if request.xhr? |
|
244 | 244 | } |
|
245 | 245 | format.atom { |
|
246 | 246 | title = l(:label_activity) |
|
247 | 247 | if @author |
|
248 | 248 | title = @author.name |
|
249 | 249 | elsif @activity.scope.size == 1 |
|
250 | 250 | title = l("label_#{@activity.scope.first.singularize}_plural") |
|
251 | 251 | end |
|
252 | 252 | render_feed(events, :title => "#{@project || Setting.app_title}: #{title}") |
|
253 | 253 | } |
|
254 | 254 | end |
|
255 | 255 | |
|
256 | 256 | rescue ActiveRecord::RecordNotFound |
|
257 | 257 | render_404 |
|
258 | 258 | end |
|
259 | 259 | |
|
260 | 260 | private |
|
261 | 261 | # Find project of id params[:id] |
|
262 | 262 | # if not found, redirect to project list |
|
263 | 263 | # Used as a before_filter |
|
264 | 264 | def find_project |
|
265 | 265 | @project = Project.find(params[:id]) |
|
266 | 266 | rescue ActiveRecord::RecordNotFound |
|
267 | 267 | render_404 |
|
268 | 268 | end |
|
269 | 269 | |
|
270 | 270 | def find_optional_project |
|
271 | 271 | return true unless params[:id] |
|
272 | 272 | @project = Project.find(params[:id]) |
|
273 | 273 | authorize |
|
274 | 274 | rescue ActiveRecord::RecordNotFound |
|
275 | 275 | render_404 |
|
276 | 276 | end |
|
277 | 277 | |
|
278 | 278 | def retrieve_selected_tracker_ids(selectable_trackers) |
|
279 | 279 | if ids = params[:tracker_ids] |
|
280 | 280 | @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s } |
|
281 | 281 | else |
|
282 | 282 | @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s } |
|
283 | 283 | end |
|
284 | 284 | end |
|
285 | 285 | end |
@@ -1,60 +1,60 | |||
|
1 | 1 | <h2><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)) %></h2> |
|
2 | 2 | <p class="subtitle"><%= "#{l(:label_date_from)} #{format_date(@date_to - @days)} #{l(:label_date_to).downcase} #{format_date(@date_to-1)}" %></p> |
|
3 | 3 | |
|
4 | 4 | <div id="activity"> |
|
5 | 5 | <% @events_by_day.keys.sort.reverse.each do |day| %> |
|
6 | 6 | <h3><%= format_activity_day(day) %></h3> |
|
7 | 7 | <dl> |
|
8 | 8 | <% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%> |
|
9 | 9 | <dt class="<%= e.event_type %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>"> |
|
10 | 10 | <%= avatar(e.event_author, :size => "24") if e.respond_to?(:event_author) %> |
|
11 | 11 | <span class="time"><%= format_time(e.event_datetime, false) %></span> |
|
12 | 12 | <%= content_tag('span', h(e.project), :class => 'project') if @project.nil? || @project != e.project %> |
|
13 | 13 | <%= link_to format_activity_title(e.event_title), e.event_url %></dt> |
|
14 | 14 | <dd><span class="description"><%= format_activity_description(e.event_description) %></span> |
|
15 | 15 | <span class="author"><%= e.event_author if e.respond_to?(:event_author) %></span></dd> |
|
16 | 16 | <% end -%> |
|
17 | 17 | </dl> |
|
18 | 18 | <% end -%> |
|
19 | 19 | </div> |
|
20 | 20 | |
|
21 | 21 | <%= content_tag('p', l(:label_no_data), :class => 'nodata') if @events_by_day.empty? %> |
|
22 | 22 | |
|
23 | 23 | <div style="float:left;"> |
|
24 | 24 | <%= link_to_remote(('« ' + l(:label_previous)), |
|
25 | 25 | {:update => "content", :url => params.merge(:from => @date_to - @days - 1), :complete => 'window.scrollTo(0,0)'}, |
|
26 | 26 | {:href => url_for(params.merge(:from => @date_to - @days - 1)), |
|
27 | 27 | :title => "#{l(:label_date_from)} #{format_date(@date_to - 2*@days)} #{l(:label_date_to).downcase} #{format_date(@date_to - @days - 1)}"}) %> |
|
28 | 28 | </div> |
|
29 | 29 | <div style="float:right;"> |
|
30 | 30 | <%= link_to_remote((l(:label_next) + ' »'), |
|
31 | 31 | {:update => "content", :url => params.merge(:from => @date_to + @days - 1), :complete => 'window.scrollTo(0,0)'}, |
|
32 | 32 | {:href => url_for(params.merge(:from => @date_to + @days - 1)), |
|
33 | 33 | :title => "#{l(:label_date_from)} #{format_date(@date_to)} #{l(:label_date_to).downcase} #{format_date(@date_to + @days - 1)}"}) unless @date_to >= Date.today %> |
|
34 | 34 | </div> |
|
35 | 35 | |
|
36 | 36 | <p class="other-formats"> |
|
37 | 37 | <%= l(:label_export_to) %> |
|
38 | 38 | <%= link_to 'Atom', params.merge(:format => :atom, :from => nil, :key => User.current.rss_key), :class => 'feed' %> |
|
39 | 39 | </p> |
|
40 | 40 | |
|
41 | 41 | <% content_for :header_tags do %> |
|
42 | 42 | <%= auto_discovery_link_tag(:atom, params.merge(:format => 'atom', :from => nil, :key => User.current.rss_key)) %> |
|
43 | 43 | <% end %> |
|
44 | 44 | |
|
45 | 45 | <% content_for :sidebar do %> |
|
46 | 46 | <% form_tag({}, :method => :get) do %> |
|
47 | 47 | <h3><%= l(:label_activity) %></h3> |
|
48 | 48 | <p><% @activity.event_types.each do |t| %> |
|
49 | 49 | <label><%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %> <%= l("label_#{t.singularize}_plural")%></label><br /> |
|
50 | 50 | <% end %></p> |
|
51 | 51 | <% if @project && @project.active_children.any? %> |
|
52 | 52 | <p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p> |
|
53 | 53 | <%= hidden_field_tag 'with_subprojects', 0 %> |
|
54 | 54 | <% end %> |
|
55 |
<%= hidden_field_tag |
|
|
55 | <%= hidden_field_tag('user_id', params[:user_id]) unless params[:user_id].blank? %> | |
|
56 | 56 | <p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p> |
|
57 | 57 | <% end %> |
|
58 | 58 | <% end %> |
|
59 | 59 | |
|
60 | 60 | <% html_title(l(:label_activity), @author) -%> |
General Comments 0
You need to be logged in to leave comments.
Login now