Patch #33664 » acts_as_activity_provider-v2.patch
app/models/attachment.rb | ||
---|---|---|
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 { |
|
42 |
select("#{Attachment.table_name}.*"). |
|
42 | 43 |
joins("LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " + |
43 | 44 |
"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 )") |
45 |
} |
|
44 | 46 | |
45 | 47 |
acts_as_activity_provider :type => 'documents', |
46 | 48 |
:permission => :view_documents, |
47 | 49 |
:author_key => :author_id, |
48 |
:scope => select("#{Attachment.table_name}.*"). |
|
50 |
:scope => proc { |
|
51 |
select("#{Attachment.table_name}.*"). |
|
49 | 52 |
joins("LEFT JOIN #{Document.table_name} ON #{Attachment.table_name}.container_type='Document' AND #{Document.table_name}.id = #{Attachment.table_name}.container_id " + |
50 | 53 |
"LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id") |
54 |
} |
|
51 | 55 | |
52 | 56 |
cattr_accessor :storage_path |
53 | 57 |
@@storage_path = Redmine::Configuration['attachments_storage_path'] || File.join(Rails.root, "files") |
app/models/changeset.rb | ||
---|---|---|
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 |
app/models/document.rb | ||
---|---|---|
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 |
app/models/issue.rb | ||
---|---|---|
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) |
app/models/journal.rb | ||
---|---|---|
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 { |
|
42 |
preload({:issue => :project}, :user). |
|
42 | 43 |
joins("LEFT OUTER JOIN #{JournalDetail.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id"). |
43 | 44 |
where("#{Journal.table_name}.journalized_type = 'Issue' AND" + |
44 | 45 |
" (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')").distinct |
46 |
} |
|
45 | 47 | |
46 | 48 |
before_create :split_private_notes |
47 | 49 |
after_create_commit :send_notification |
app/models/message.rb | ||
---|---|---|
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 |
app/models/news.rb | ||
---|---|---|
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 |
app/models/time_entry.rb | ||
---|---|---|
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') } |
app/models/wiki_content_version.rb | ||
---|---|---|
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 { |
|
38 |
select("#{table_name}.updated_on, #{table_name}.comments, " + |
|
38 | 39 |
"#{table_name}.version, #{WikiPage.table_name}.title, " + |
39 | 40 |
"#{table_name}.page_id, #{table_name}.author_id, " + |
40 | 41 |
"#{table_name}.id"). |
41 | 42 |
joins("LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{table_name}.page_id " + |
42 | 43 |
"LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id " + |
43 | 44 |
"LEFT JOIN #{Project.table_name} ON #{Project.table_name}.id = #{Wiki.table_name}.project_id") |
45 |
} |
|
44 | 46 | |
45 | 47 |
after_destroy :page_update_after_destroy |
46 | 48 |
extra/sample_plugin/app/models/meeting.rb | ||
---|---|---|
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 |
lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb | ||
---|---|---|
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) |
- « Previous
- 1
- 2
- Next »