To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / app / controllers / activities_controller.rb @ 1015:52be96e83080
History | View | Annotate | Download (3.32 KB)
| 1 | 507:0c939c159af4 | Chris | # Redmine - project management software
|
|---|---|---|---|
| 2 | # Copyright (C) 2006-2011 Jean-Philippe Lang
|
||
| 3 | #
|
||
| 4 | # This program is free software; you can redistribute it and/or
|
||
| 5 | # modify it under the terms of the GNU General Public License
|
||
| 6 | # as published by the Free Software Foundation; either version 2
|
||
| 7 | # of the License, or (at your option) any later version.
|
||
| 8 | #
|
||
| 9 | # This program is distributed in the hope that it will be useful,
|
||
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
| 12 | # GNU General Public License for more details.
|
||
| 13 | #
|
||
| 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
|
||
| 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
| 17 | |||
| 18 | 22:40f7cfd4df19 | chris | class ActivitiesController < ApplicationController |
| 19 | menu_item :activity
|
||
| 20 | before_filter :find_optional_project
|
||
| 21 | 507:0c939c159af4 | Chris | accept_rss_auth :index
|
| 22 | 22:40f7cfd4df19 | chris | |
| 23 | def index |
||
| 24 | @days = Setting.activity_days_default.to_i |
||
| 25 | 441:cbce1fd3b1b7 | Chris | |
| 26 | 22:40f7cfd4df19 | chris | if params[:from] |
| 27 | begin; @date_to = params[:from].to_date + 1; rescue; end |
||
| 28 | end
|
||
| 29 | |||
| 30 | @date_to ||= Date.today + 1 |
||
| 31 | @date_from = @date_to - @days |
||
| 32 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') |
||
| 33 | @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id])) |
||
| 34 | 441:cbce1fd3b1b7 | Chris | |
| 35 | @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project, |
||
| 36 | 22:40f7cfd4df19 | chris | :with_subprojects => @with_subprojects, |
| 37 | :author => @author) |
||
| 38 | @activity.scope_select {|t| !params["show_#{t}"].nil?} |
||
| 39 | @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty? |
||
| 40 | |||
| 41 | events = @activity.events(@date_from, @date_to) |
||
| 42 | 441:cbce1fd3b1b7 | Chris | |
| 43 | 1009:066b55d7c053 | chris | @institution_name = params[:institution] |
| 44 | if !@institution_name.blank? |
||
| 45 | events = events.select do |e|
|
||
| 46 | e.respond_to?(:event_author) and e.event_author and |
||
| 47 | 1014:e3f78fa30a36 | Chris | e.event_author.respond_to?(:ssamr_user_detail) and |
| 48 | !e.event_author.ssamr_user_detail.nil? and
|
||
| 49 | 1009:066b55d7c053 | chris | e.event_author.ssamr_user_detail.institution_name == @institution_name
|
| 50 | end
|
||
| 51 | if events.empty?
|
||
| 52 | # We don't want to dump into the output any arbitrary string
|
||
| 53 | # from the URL that has no matching events
|
||
| 54 | @institution_name = "" |
||
| 55 | end
|
||
| 56 | end
|
||
| 57 | |||
| 58 | if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, @institution_name, events.first, User.current, current_language]) |
||
| 59 | 22:40f7cfd4df19 | chris | respond_to do |format|
|
| 60 | 441:cbce1fd3b1b7 | Chris | format.html {
|
| 61 | 22:40f7cfd4df19 | chris | @events_by_day = events.group_by(&:event_date) |
| 62 | render :layout => false if request.xhr? |
||
| 63 | } |
||
| 64 | format.atom {
|
||
| 65 | title = l(:label_activity)
|
||
| 66 | if @author |
||
| 67 | title = @author.name
|
||
| 68 | elsif @activity.scope.size == 1 |
||
| 69 | title = l("label_#{@activity.scope.first.singularize}_plural")
|
||
| 70 | end
|
||
| 71 | render_feed(events, :title => "#{@project || Setting.app_title}: #{title}") |
||
| 72 | } |
||
| 73 | end
|
||
| 74 | end
|
||
| 75 | 441:cbce1fd3b1b7 | Chris | |
| 76 | 22:40f7cfd4df19 | chris | rescue ActiveRecord::RecordNotFound |
| 77 | render_404 |
||
| 78 | end
|
||
| 79 | |||
| 80 | private |
||
| 81 | |||
| 82 | # TODO: refactor, duplicated in projects_controller
|
||
| 83 | def find_optional_project |
||
| 84 | return true unless params[:id] |
||
| 85 | @project = Project.find(params[:id]) |
||
| 86 | authorize |
||
| 87 | rescue ActiveRecord::RecordNotFound |
||
| 88 | render_404 |
||
| 89 | end
|
||
| 90 | end |