Class: ActivitiesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/activities_controller.rb

Overview

– copyright ChiliProject is a project management system.

Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

See doc/COPYRIGHT.rdoc for more details. ++

Instance Method Summary collapse

Methods included from Redmine::MenuManager::MenuController

#current_menu_item, included, #menu_items, #redirect_to_project_menu_item

Methods included from Redmine::Search::Controller

#default_search_scope, #default_search_scopes, included

Methods included from Redmine::I18n

#current_language, #day_name, #find_language, #format_date, #format_time, included, #l, #l_hours, #l_or_humanize, #ll, #month_name, #set_language_if_valid, #valid_languages

Instance Method Details

#indexObject


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/activities_controller.rb', line 20

def index
  @days = Setting.activity_days_default.to_i

  if params[:from]
    begin; @date_to = params[:from].to_date + 1; rescue; end
  end

  @date_to ||= Date.today + 1
  @date_from = @date_to - @days
  @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
  @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))

  @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project,
                                                           :with_subprojects => @with_subprojects,
                                                           :author => @author)
  @activity.scope_select {|t| !params["show_#{t}"].nil?}
  @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty? unless params[:set_filter]

  events = @activity.events(@date_from, @date_to)

  if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language])
    respond_to do |format|
      format.html {
        @events_by_day = events.group_by(&:event_date)
        render :layout => false if request.xhr?
      }
      format.atom {
        title = l(:label_activity)
        if @author
          title = @author.name
        elsif @activity.scope.size == 1
          title = l("label_#{@activity.scope.first.singularize}_plural")
        end
        render_feed(events, :title => "#{@project || Setting.app_title}: #{title}")
      }
    end
  end

rescue ActiveRecord::RecordNotFound
  render_404
end