Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

activities_controller.rb 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # 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. class ActivitiesController < ApplicationController
  18. menu_item :activity
  19. before_filter :find_optional_project
  20. accept_rss_auth :index
  21. def index
  22. @days = Setting.activity_days_default.to_i
  23. if params[:from]
  24. begin; @date_to = params[:from].to_date + 1; rescue; end
  25. end
  26. @date_to ||= Date.today + 1
  27. @date_from = @date_to - @days
  28. @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
  29. @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
  30. @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project,
  31. :with_subprojects => @with_subprojects,
  32. :author => @author)
  33. @activity.scope_select {|t| !params["show_#{t}"].nil?}
  34. @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
  35. events = @activity.events(@date_from, @date_to)
  36. if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language])
  37. respond_to do |format|
  38. format.html {
  39. @events_by_day = events.group_by(&:event_date)
  40. render :layout => false if request.xhr?
  41. }
  42. format.atom {
  43. title = l(:label_activity)
  44. if @author
  45. title = @author.name
  46. elsif @activity.scope.size == 1
  47. title = l("label_#{@activity.scope.first.singularize}_plural")
  48. end
  49. render_feed(events, :title => "#{@project || Setting.app_title}: #{title}")
  50. }
  51. end
  52. end
  53. rescue ActiveRecord::RecordNotFound
  54. render_404
  55. end
  56. private
  57. # TODO: refactor, duplicated in projects_controller
  58. def find_optional_project
  59. return true unless params[:id]
  60. @project = Project.find(params[:id])
  61. authorize
  62. rescue ActiveRecord::RecordNotFound
  63. render_404
  64. end
  65. end