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")