remove trailing white-spaces from vendor/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9301 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
b054ccf9c7
commit
0e7a2dd688
|
@ -1,16 +1,16 @@
|
||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2008 Jean-Philippe Lang
|
# Copyright (C) 2006-2012 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
@ -31,11 +31,11 @@ module Redmine
|
||||||
|
|
||||||
options.assert_valid_keys(:type, :permission, :timestamp, :author_key, :find_options)
|
options.assert_valid_keys(:type, :permission, :timestamp, :author_key, :find_options)
|
||||||
self.activity_provider_options ||= {}
|
self.activity_provider_options ||= {}
|
||||||
|
|
||||||
# One model can provide different event types
|
# One model can provide different event types
|
||||||
# We store these options in activity_provider_options hash
|
# We store these options in activity_provider_options hash
|
||||||
event_type = options.delete(:type) || self.name.underscore.pluralize
|
event_type = options.delete(:type) || self.name.underscore.pluralize
|
||||||
|
|
||||||
options[:timestamp] ||= "#{table_name}.created_on"
|
options[:timestamp] ||= "#{table_name}.created_on"
|
||||||
options[:find_options] ||= {}
|
options[:find_options] ||= {}
|
||||||
options[:author_key] = "#{table_name}.#{options[:author_key]}" if options[:author_key].is_a?(Symbol)
|
options[:author_key] = "#{table_name}.#{options[:author_key]}" if options[:author_key].is_a?(Symbol)
|
||||||
|
@ -47,29 +47,29 @@ module Redmine
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
base.extend ClassMethods
|
base.extend ClassMethods
|
||||||
end
|
end
|
||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
# Returns events of type event_type visible by user that occured between from and to
|
# Returns events of type event_type visible by user that occured between from and to
|
||||||
def find_events(event_type, user, from, to, options)
|
def find_events(event_type, user, from, to, options)
|
||||||
provider_options = activity_provider_options[event_type]
|
provider_options = activity_provider_options[event_type]
|
||||||
raise "#{self.name} can not provide #{event_type} events." if provider_options.nil?
|
raise "#{self.name} can not provide #{event_type} events." if provider_options.nil?
|
||||||
|
|
||||||
scope = self
|
scope = self
|
||||||
|
|
||||||
if from && to
|
if from && to
|
||||||
scope = scope.scoped(:conditions => ["#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to])
|
scope = scope.scoped(:conditions => ["#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to])
|
||||||
end
|
end
|
||||||
|
|
||||||
if options[:author]
|
if options[:author]
|
||||||
return [] if provider_options[:author_key].nil?
|
return [] if provider_options[:author_key].nil?
|
||||||
scope = scope.scoped(:conditions => ["#{provider_options[:author_key]} = ?", options[:author].id])
|
scope = scope.scoped(:conditions => ["#{provider_options[:author_key]} = ?", options[:author].id])
|
||||||
end
|
end
|
||||||
|
|
||||||
if options[:limit]
|
if options[:limit]
|
||||||
# id and creation time should be in same order in most cases
|
# id and creation time should be in same order in most cases
|
||||||
scope = scope.scoped(:order => "#{table_name}.id DESC", :limit => options[:limit])
|
scope = scope.scoped(:order => "#{table_name}.id DESC", :limit => options[:limit])
|
||||||
end
|
end
|
||||||
|
|
||||||
if provider_options.has_key?(:permission)
|
if provider_options.has_key?(:permission)
|
||||||
scope = scope.scoped(:conditions => Project.allowed_to_condition(user, provider_options[:permission] || :view_project, options))
|
scope = scope.scoped(:conditions => Project.allowed_to_condition(user, provider_options[:permission] || :view_project, options))
|
||||||
elsif respond_to?(:visible)
|
elsif respond_to?(:visible)
|
||||||
|
@ -78,7 +78,7 @@ module Redmine
|
||||||
ActiveSupport::Deprecation.warn "acts_as_activity_provider with implicit :permission option is deprecated. Add a visible scope to the #{self.name} model or use explicit :permission option."
|
ActiveSupport::Deprecation.warn "acts_as_activity_provider with implicit :permission option is deprecated. Add a visible scope to the #{self.name} model or use explicit :permission option."
|
||||||
scope = scope.scoped(:conditions => Project.allowed_to_condition(user, "view_#{self.name.underscore.pluralize}".to_sym, options))
|
scope = scope.scoped(:conditions => Project.allowed_to_condition(user, "view_#{self.name.underscore.pluralize}".to_sym, options))
|
||||||
end
|
end
|
||||||
|
|
||||||
scope.all(provider_options[:find_options].dup)
|
scope.all(provider_options[:find_options].dup)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue