You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

activities_controller.rb 3.4 kB

13 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
13 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
13 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2013 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, :index
  20. accept_rss_auth :index
  21. helper :Watchers
  22. helper :project_score
  23. def index
  24. @days = Setting.activity_days_default.to_i
  25. if params[:from]
  26. begin; @date_to = params[:from].to_date + 1; rescue; end
  27. end
  28. has = {
  29. "show_issues" => true
  30. }
  31. @date_to ||= Date.today + 1
  32. @date_from = @date_to - @days
  33. @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
  34. @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
  35. # 决定显示所用用户或单个用户活动
  36. @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project,
  37. :with_subprojects => @with_subprojects,
  38. :author => @author)
  39. @activity.scope_select {|t| !has["show_#{t}"].nil?}
  40. #@activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
  41. events = @activity.events(@date_from, @date_to)
  42. # Added by Nie.
  43. @offset, @limit = api_offset_and_limit({:limit => 10})
  44. @activity_count = events.size
  45. @activity_pages = Paginator.new @activity_count, @limit, params['page']
  46. @offset ||= @activity_pages.offset
  47. @project_base_tag = params[:id] ? 'base_projects' : 'base'
  48. if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, events.size, User.current, current_language])
  49. respond_to do |format|
  50. format.html {
  51. @events_by_day_ = events.slice(@offset,@limit)
  52. @events_by_day = @events_by_day_.group_by {|event| User.current.time_to_date(event.event_datetime)}
  53. #by young render :layout => false if request.xhr?
  54. render :layout => @project_base_tag
  55. }
  56. format.atom {
  57. title = l(:label_activity)
  58. if @author
  59. title = @author.name
  60. elsif @activity.scope.size == 1
  61. title = l("label_#{@activity.scope.first.singularize}_plural")
  62. end
  63. render_feed(events, :title => "#{@project || Setting.app_title}: #{title}")
  64. }
  65. end
  66. end
  67. rescue ActiveRecord::RecordNotFound
  68. render_404
  69. end
  70. private
  71. # TODO: refactor, duplicated in projects_controller
  72. def find_optional_project
  73. return true unless params[:id]
  74. @project = Project.find(params[:id])
  75. authorize
  76. rescue ActiveRecord::RecordNotFound
  77. render_404
  78. end
  79. end

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...