mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-22 08:21:14 +00:00
shorten long line of app/models/attachment.rb
git-svn-id: http://svn.redmine.org/redmine/trunk@20158 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
5c14d09e25
commit
bf3f2e19d3
@ -32,26 +32,36 @@ class Attachment < ActiveRecord::Base
|
||||
validates_length_of :description, :maximum => 255
|
||||
validate :validate_max_file_size, :validate_file_extension
|
||||
|
||||
acts_as_event :title => :filename,
|
||||
:url => Proc.new {|o| {:controller => 'attachments', :action => 'show', :id => o.id, :filename => o.filename}}
|
||||
|
||||
acts_as_activity_provider :type => 'files',
|
||||
:permission => :view_files,
|
||||
:author_key => :author_id,
|
||||
:scope => proc {
|
||||
select("#{Attachment.table_name}.*").
|
||||
joins("LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " +
|
||||
"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 )")
|
||||
}
|
||||
|
||||
acts_as_activity_provider :type => 'documents',
|
||||
:permission => :view_documents,
|
||||
:author_key => :author_id,
|
||||
:scope => proc {
|
||||
select("#{Attachment.table_name}.*").
|
||||
joins("LEFT JOIN #{Document.table_name} ON #{Attachment.table_name}.container_type='Document' AND #{Document.table_name}.id = #{Attachment.table_name}.container_id " +
|
||||
"LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id")
|
||||
}
|
||||
acts_as_event(
|
||||
:title => :filename,
|
||||
:url =>
|
||||
Proc.new do |o|
|
||||
{:controller => 'attachments', :action => 'show',
|
||||
:id => o.id, :filename => o.filename}
|
||||
end
|
||||
)
|
||||
acts_as_activity_provider(
|
||||
:type => 'files',
|
||||
:permission => :view_files,
|
||||
:author_key => :author_id,
|
||||
:scope =>
|
||||
proc do
|
||||
select("#{Attachment.table_name}.*").
|
||||
joins("LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " +
|
||||
"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 )")
|
||||
end
|
||||
)
|
||||
acts_as_activity_provider(
|
||||
:type => 'documents',
|
||||
:permission => :view_documents,
|
||||
:author_key => :author_id,
|
||||
:scope =>
|
||||
proc do
|
||||
select("#{Attachment.table_name}.*").
|
||||
joins("LEFT JOIN #{Document.table_name} ON #{Attachment.table_name}.container_type='Document' AND #{Document.table_name}.id = #{Attachment.table_name}.container_id " +
|
||||
"LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id")
|
||||
end
|
||||
)
|
||||
|
||||
cattr_accessor :storage_path
|
||||
@@storage_path = Redmine::Configuration['attachments_storage_path'] || File.join(Rails.root, "files")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user