fix display of attachments with acts_as_journalized
This commit is contained in:
parent
f45bb1e85e
commit
cea1a987ab
@ -28,23 +28,23 @@ class Attachment < ActiveRecord::Base
|
|||||||
acts_as_journalized :event_title => :filename,
|
acts_as_journalized :event_title => :filename,
|
||||||
:event_url => (Proc.new do |o|
|
:event_url => (Proc.new do |o|
|
||||||
{ :controller => 'attachments', :action => 'download',
|
{ :controller => 'attachments', :action => 'download',
|
||||||
:id => o.id, :filename => o.filename }
|
:id => o.versioned_id, :filename => o.filename }
|
||||||
end),
|
end),
|
||||||
:activity_type => 'files',
|
:activity_type => 'files',
|
||||||
:activity_permission => :view_files,
|
:activity_permission => :view_files
|
||||||
:activity_find_options => {:select => "#{Attachment.table_name}.*",
|
|
||||||
:joins => "LEFT JOIN #{Version.table_name} ON #{Version.table_name}.id = #{Attachment.table_name}.container_id " +
|
|
||||||
" AND #{Attachment.table_name}.container_type = 'Version' " +
|
|
||||||
"LEFT JOIN #{Project.table_name} ON #{Project.table_name}.id = #{Version.table_name}.project_id " +
|
|
||||||
" OR ( #{Attachment.table_name}.container_id = #{Project.table_name}.id " +
|
|
||||||
" AND #{Attachment.table_name}.container_type = 'Project' ) " }
|
|
||||||
|
|
||||||
acts_as_activity :type => 'documents',
|
acts_as_activity :type => 'documents', :permission => :view_documents
|
||||||
:permission => :view_documents,
|
|
||||||
:find_options => {:select => "#{Attachment.table_name}.*",
|
def activity_type
|
||||||
:joins => "LEFT JOIN #{Document.table_name} ON (#{Document.table_name}.id = #{Attachment.table_name}.container_id" +
|
case container_type
|
||||||
" AND #{Attachment.table_name}.container_type='Document') " +
|
when "Document"
|
||||||
"LEFT JOIN #{Project.table_name} ON (#{Project.table_name}.id = #{Document.table_name}.project_id)" }
|
"documents"
|
||||||
|
when "Version"
|
||||||
|
"files"
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
cattr_accessor :storage_path
|
cattr_accessor :storage_path
|
||||||
@@storage_path = "#{RAILS_ROOT}/files"
|
@@storage_path = "#{RAILS_ROOT}/files"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user