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

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