annotate app/controllers/.svn/text-base/activities_controller.rb.svn-base @ 45:65d9e2cabaa3 luisf

Added tipoftheday to the config/settings in order to correct previous issues. Tip of the day is now working correctly. Added the heading strings to the locales files.
author luisf
date Tue, 23 Nov 2010 11:50:01 +0000
parents 40f7cfd4df19
children af80e5618e9b
rev   line source
chris@22 1 class ActivitiesController < ApplicationController
chris@22 2 menu_item :activity
chris@22 3 before_filter :find_optional_project
chris@22 4 accept_key_auth :index
chris@22 5
chris@22 6 def index
chris@22 7 @days = Setting.activity_days_default.to_i
chris@22 8
chris@22 9 if params[:from]
chris@22 10 begin; @date_to = params[:from].to_date + 1; rescue; end
chris@22 11 end
chris@22 12
chris@22 13 @date_to ||= Date.today + 1
chris@22 14 @date_from = @date_to - @days
chris@22 15 @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
chris@22 16 @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
chris@22 17
chris@22 18 @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project,
chris@22 19 :with_subprojects => @with_subprojects,
chris@22 20 :author => @author)
chris@22 21 @activity.scope_select {|t| !params["show_#{t}"].nil?}
chris@22 22 @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
chris@22 23
chris@22 24 events = @activity.events(@date_from, @date_to)
chris@22 25
chris@22 26 if events.empty? || stale?(:etag => [events.first, User.current])
chris@22 27 respond_to do |format|
chris@22 28 format.html {
chris@22 29 @events_by_day = events.group_by(&:event_date)
chris@22 30 render :layout => false if request.xhr?
chris@22 31 }
chris@22 32 format.atom {
chris@22 33 title = l(:label_activity)
chris@22 34 if @author
chris@22 35 title = @author.name
chris@22 36 elsif @activity.scope.size == 1
chris@22 37 title = l("label_#{@activity.scope.first.singularize}_plural")
chris@22 38 end
chris@22 39 render_feed(events, :title => "#{@project || Setting.app_title}: #{title}")
chris@22 40 }
chris@22 41 end
chris@22 42 end
chris@22 43
chris@22 44 rescue ActiveRecord::RecordNotFound
chris@22 45 render_404
chris@22 46 end
chris@22 47
chris@22 48 private
chris@22 49
chris@22 50 # TODO: refactor, duplicated in projects_controller
chris@22 51 def find_optional_project
chris@22 52 return true unless params[:id]
chris@22 53 @project = Project.find(params[:id])
chris@22 54 authorize
chris@22 55 rescue ActiveRecord::RecordNotFound
chris@22 56 render_404
chris@22 57 end
chris@22 58
chris@22 59 end