mirror of
https://github.com/redmine/redmine.git
synced 2025-11-01 10:56:17 +01:00
Depending on the offset between a user's configured timezone and the server timezone, Date.today may be more or less often wrong from the user's perspective, leading to things like issues marked as overdue too early or too late, or yesterday / tomorrow being displayed / selected where 'today' is intended. A test case illustrating the problem with Issue#overdue? is included Patch by Jens Kraemer. git-svn-id: http://svn.redmine.org/redmine/trunk@15379 e93f8b46-1217-0410-a6f0-8f06a7374b81
91 lines
3.1 KiB
Ruby
91 lines
3.1 KiB
Ruby
# Redmine - project management software
|
|
# Copyright (C) 2006-2016 Jean-Philippe Lang
|
|
#
|
|
# 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.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
class ActivitiesController < ApplicationController
|
|
menu_item :activity
|
|
before_filter :find_optional_project
|
|
accept_rss_auth :index
|
|
|
|
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 ||= User.current.today + 1
|
|
@date_from = @date_to - @days
|
|
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
|
|
if params[:user_id].present?
|
|
@author = User.active.find(params[:user_id])
|
|
end
|
|
|
|
@activity = Redmine::Activity::Fetcher.new(User.current, :project => @project,
|
|
:with_subprojects => @with_subprojects,
|
|
:author => @author)
|
|
pref = User.current.pref
|
|
@activity.scope_select {|t| !params["show_#{t}"].nil?}
|
|
if @activity.scope.present?
|
|
if params[:submit].present?
|
|
pref.activity_scope = @activity.scope
|
|
pref.save
|
|
end
|
|
else
|
|
if @author.nil?
|
|
scope = pref.activity_scope & @activity.event_types
|
|
@activity.scope = scope.present? ? scope : :default
|
|
else
|
|
@activity.scope = :all
|
|
end
|
|
end
|
|
|
|
events = @activity.events(@date_from, @date_to)
|
|
|
|
if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, events.size, User.current, current_language])
|
|
respond_to do |format|
|
|
format.html {
|
|
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
|
|
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
|
|
|
|
private
|
|
|
|
# TODO: refactor, duplicated in projects_controller
|
|
def find_optional_project
|
|
return true unless params[:id]
|
|
@project = Project.find(params[:id])
|
|
authorize
|
|
rescue ActiveRecord::RecordNotFound
|
|
render_404
|
|
end
|
|
end
|