mirror of
https://github.com/redmine/redmine.git
synced 2025-11-14 01:06:00 +01:00
Fix missing deletion of custom field attachments upon issue deletion (#38966).
Patch by Takenori TAKAKI (user:takenory). git-svn-id: https://svn.redmine.org/redmine/trunk@23161 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -29,6 +29,7 @@ module Redmine
|
||||
return if self.included_modules.include?(Redmine::Acts::Customizable::InstanceMethods)
|
||||
cattr_accessor :customizable_options
|
||||
self.customizable_options = options
|
||||
before_destroy :store_attachment_custom_value_ids
|
||||
has_many :custom_values, lambda {includes(:custom_field)},
|
||||
:as => :customized,
|
||||
:inverse_of => :customized,
|
||||
@@ -38,6 +39,7 @@ module Redmine
|
||||
send :include, Redmine::Acts::Customizable::InstanceMethods
|
||||
validate :validate_custom_field_values
|
||||
after_save :save_custom_field_values
|
||||
after_destroy :destroy_custom_value_attachments
|
||||
end
|
||||
end
|
||||
|
||||
@@ -170,6 +172,17 @@ module Redmine
|
||||
super
|
||||
end
|
||||
|
||||
def store_attachment_custom_value_ids
|
||||
@attachment_custom_value_ids =
|
||||
custom_values.select {|cv| cv.custom_field.field_format == 'attachment'}
|
||||
.map(&:id)
|
||||
end
|
||||
|
||||
def destroy_custom_value_attachments
|
||||
Attachment.where(:container_id => @attachment_custom_value_ids, :container_type => 'CustomValue')
|
||||
.destroy_all
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user