Patch #33664 » acts_as_activity_provider.patch
trunk/app/models/attachment.rb (revision 19833) → trunk/app/models/attachment.rb (working copy) | ||
---|---|---|
38 | 38 |
acts_as_activity_provider :type => 'files', |
39 | 39 |
:permission => :view_files, |
40 | 40 |
:author_key => :author_id, |
41 |
:scope => select("#{Attachment.table_name}.*"). |
|
41 |
:scope => proc { select("#{Attachment.table_name}.*").
|
|
42 | 42 |
joins("LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " + |
43 |
"LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id OR ( #{Attachment.table_name}.container_type='Project' AND #{Attachment.table_name}.container_id = #{Project.table_name}.id )") |
|
43 |
"LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id OR ( #{Attachment.table_name}.container_type='Project' AND #{Attachment.table_name}.container_id = #{Project.table_name}.id )") }
|
|
44 | 44 | |
45 | 45 |
acts_as_activity_provider :type => 'documents', |
46 | 46 |
:permission => :view_documents, |
47 | 47 |
:author_key => :author_id, |
48 |
:scope => select("#{Attachment.table_name}.*"). |
|
48 |
:scope => proc { select("#{Attachment.table_name}.*").
|
|
49 | 49 |
joins("LEFT JOIN #{Document.table_name} ON #{Attachment.table_name}.container_type='Document' AND #{Document.table_name}.id = #{Attachment.table_name}.container_id " + |
50 |
"LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id") |
|
50 |
"LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id") }
|
|
51 | 51 | |
52 | 52 |
cattr_accessor :storage_path |
53 | 53 |
@@storage_path = Redmine::Configuration['attachments_storage_path'] || File.join(Rails.root, "files") |
trunk/app/models/changeset.rb (revision 19833) → trunk/app/models/changeset.rb (working copy) | ||
---|---|---|
43 | 43 | |
44 | 44 |
acts_as_activity_provider :timestamp => "#{table_name}.committed_on", |
45 | 45 |
:author_key => :user_id, |
46 |
:scope => preload(:user, {:repository => :project})
|
|
46 |
:scope => proc { preload(:user, {:repository => :project}) }
|
|
47 | 47 | |
48 | 48 |
validates_presence_of :repository_id, :revision, :committed_on, :commit_date |
49 | 49 |
validates_uniqueness_of :revision, :scope => :repository_id |
trunk/app/models/document.rb (revision 19833) → trunk/app/models/document.rb (working copy) | ||
---|---|---|
29 | 29 |
acts_as_event :title => Proc.new {|o| "#{l(:label_document)}: #{o.title}"}, |
30 | 30 |
:author => Proc.new {|o| o.attachments.reorder("#{Attachment.table_name}.created_on ASC").first.try(:author) }, |
31 | 31 |
:url => Proc.new {|o| {:controller => 'documents', :action => 'show', :id => o.id}} |
32 |
acts_as_activity_provider :scope => preload(:project)
|
|
32 |
acts_as_activity_provider :scope => proc { preload(:project) }
|
|
33 | 33 | |
34 | 34 |
validates_presence_of :project, :title, :category |
35 | 35 |
validates_length_of :title, :maximum => 255 |
trunk/app/models/issue.rb (revision 19833) → trunk/app/models/issue.rb (working copy) | ||
---|---|---|
51 | 51 |
:url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.id}}, |
52 | 52 |
:type => Proc.new {|o| 'issue' + (o.closed? ? '-closed' : '') } |
53 | 53 | |
54 |
acts_as_activity_provider :scope => preload(:project, :author, :tracker, :status),
|
|
54 |
acts_as_activity_provider :scope => proc { preload(:project, :author, :tracker, :status) },
|
|
55 | 55 |
:author_key => :author_id |
56 | 56 | |
57 | 57 |
DONE_RATIO_OPTIONS = %w(issue_field issue_status) |
trunk/app/models/journal.rb (revision 19833) → trunk/app/models/journal.rb (working copy) | ||
---|---|---|
38 | 38 | |
39 | 39 |
acts_as_activity_provider :type => 'issues', |
40 | 40 |
:author_key => :user_id, |
41 |
:scope => preload({:issue => :project}, :user). |
|
41 |
:scope => proc { preload({:issue => :project}, :user).
|
|
42 | 42 |
joins("LEFT OUTER JOIN #{JournalDetail.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id"). |
43 | 43 |
where("#{Journal.table_name}.journalized_type = 'Issue' AND" + |
44 |
" (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')").distinct |
|
44 |
" (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')").distinct }
|
|
45 | 45 | |
46 | 46 |
before_create :split_private_notes |
47 | 47 |
after_create_commit :send_notification |
trunk/app/models/message.rb (revision 19833) → trunk/app/models/message.rb (working copy) | ||
---|---|---|
45 | 45 |
end) |
46 | 46 |
} |
47 | 47 | |
48 |
acts_as_activity_provider :scope => preload({:board => :project}, :author),
|
|
48 |
acts_as_activity_provider :scope => proc { preload({:board => :project}, :author) },
|
|
49 | 49 |
:author_key => :author_id |
50 | 50 |
acts_as_watchable |
51 | 51 |
trunk/app/models/news.rb (revision 19833) → trunk/app/models/news.rb (working copy) | ||
---|---|---|
32 | 32 |
acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], |
33 | 33 |
:preload => :project |
34 | 34 |
acts_as_event :url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.id}} |
35 |
acts_as_activity_provider :scope => preload(:project, :author),
|
|
35 |
acts_as_activity_provider :scope => proc { preload(:project, :author) },
|
|
36 | 36 |
:author_key => :author_id |
37 | 37 |
acts_as_watchable |
38 | 38 |
trunk/app/models/time_entry.rb (revision 19833) → trunk/app/models/time_entry.rb (working copy) | ||
---|---|---|
41 | 41 | |
42 | 42 |
acts_as_activity_provider :timestamp => "#{table_name}.created_on", |
43 | 43 |
:author_key => :user_id, |
44 |
:scope => joins(:project).preload(:project)
|
|
44 |
:scope => proc { joins(:project).preload(:project) }
|
|
45 | 45 | |
46 | 46 |
validates_presence_of :author_id, :user_id, :activity_id, :project_id, :hours, :spent_on |
47 | 47 |
validates_presence_of :issue_id, :if => lambda { Setting.timelog_required_fields.include?('issue_id') } |
trunk/app/models/wiki_content_version.rb (revision 19833) → trunk/app/models/wiki_content_version.rb (working copy) | ||
---|---|---|
34 | 34 |
:timestamp => "#{table_name}.updated_on", |
35 | 35 |
:author_key => "#{table_name}.author_id", |
36 | 36 |
:permission => :view_wiki_edits, |
37 |
:scope => select("#{table_name}.updated_on, #{table_name}.comments, " + |
|
37 |
:scope => proc { select("#{table_name}.updated_on, #{table_name}.comments, " +
|
|
38 | 38 |
"#{table_name}.version, #{WikiPage.table_name}.title, " + |
39 | 39 |
"#{table_name}.page_id, #{table_name}.author_id, " + |
40 | 40 |
"#{table_name}.id"). |
41 | 41 |
joins("LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{table_name}.page_id " + |
42 | 42 |
"LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id " + |
43 |
"LEFT JOIN #{Project.table_name} ON #{Project.table_name}.id = #{Wiki.table_name}.project_id") |
|
43 |
"LEFT JOIN #{Project.table_name} ON #{Project.table_name}.id = #{Wiki.table_name}.project_id") }
|
|
44 | 44 | |
45 | 45 |
after_destroy :page_update_after_destroy |
46 | 46 |
trunk/extra/sample_plugin/app/models/meeting.rb (revision 19833) → trunk/extra/sample_plugin/app/models/meeting.rb (working copy) | ||
---|---|---|
7 | 7 |
:url => Proc.new {|o| {:controller => 'meetings', :action => 'show', :id => o.id}} |
8 | 8 | |
9 | 9 |
acts_as_activity_provider :timestamp => 'scheduled_on', |
10 |
:scope => includes(:project),
|
|
10 |
:scope => proc { includes(:project) },
|
|
11 | 11 |
:permission => nil |
12 | 12 |
end |
trunk/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb (revision 19833) → trunk/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb (working copy) | ||
---|---|---|
55 | 55 |
provider_options = activity_provider_options[event_type] |
56 | 56 |
raise "#{self.name} can not provide #{event_type} events." if provider_options.nil? |
57 | 57 | |
58 |
scope = (provider_options[:scope] || self) |
|
58 |
scope = provider_options[:scope] |
|
59 |
if !scope |
|
60 |
scope = self |
|
61 |
elsif scope.respond_to?(:call) |
|
62 |
scope = scope.call |
|
63 |
else |
|
64 |
ActiveSupport::Deprecation.warn "acts_as_activity_provider with implicit :scope option is deprecated. Please pass a scope on the #{self.name} as a proc." |
|
65 |
end |
|
59 | 66 | |
60 | 67 |
if from && to |
61 | 68 |
scope = scope.where("#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to) |