mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 23:11:12 +00:00
shorten long line of app/models/attachment.rb
git-svn-id: http://svn.redmine.org/redmine/trunk@20590 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
42b05f85ea
commit
00ab304a15
@ -47,8 +47,15 @@ class Attachment < ActiveRecord::Base
|
|||||||
:scope =>
|
:scope =>
|
||||||
proc do
|
proc do
|
||||||
select("#{Attachment.table_name}.*").
|
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 " +
|
joins(
|
||||||
"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 )")
|
"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
|
end
|
||||||
)
|
)
|
||||||
acts_as_activity_provider(
|
acts_as_activity_provider(
|
||||||
@ -58,8 +65,13 @@ class Attachment < ActiveRecord::Base
|
|||||||
:scope =>
|
:scope =>
|
||||||
proc do
|
proc do
|
||||||
select("#{Attachment.table_name}.*").
|
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 " +
|
joins(
|
||||||
"LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id")
|
"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
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -240,7 +252,12 @@ class Attachment < ActiveRecord::Base
|
|||||||
begin
|
begin
|
||||||
Redmine::Thumbnail.generate(self.diskfile, target, size, is_pdf?)
|
Redmine::Thumbnail.generate(self.diskfile, target, size, is_pdf?)
|
||||||
rescue => e
|
rescue => e
|
||||||
logger.error "An error occured while generating thumbnail for #{disk_filename} to #{target}\nException was: #{e.message}" if logger
|
if logger
|
||||||
|
logger.error(
|
||||||
|
"An error occured while generating thumbnail for #{disk_filename} " \
|
||||||
|
"to #{target}\nException was: #{e.message}"
|
||||||
|
)
|
||||||
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user