mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-09 13:28:53 +08:00
Files didn't get deleted in previous commit. [fixes SCI-1150]
This commit is contained in:
parent
e72184d10d
commit
1447a34dc7
1 changed files with 11 additions and 3 deletions
|
@ -68,7 +68,7 @@ class Asset < ActiveRecord::Base
|
||||||
after_validation :filter_paperclip_errors
|
after_validation :filter_paperclip_errors
|
||||||
# Needed because Paperclip validatates on creation
|
# Needed because Paperclip validatates on creation
|
||||||
after_initialize :filter_paperclip_errors, if: :new_record?
|
after_initialize :filter_paperclip_errors, if: :new_record?
|
||||||
before_destroy :paperlip_delete, prepend: true
|
before_destroy :paperclip_delete, prepend: true
|
||||||
|
|
||||||
attr_accessor :file_content, :file_info, :preview_cached
|
attr_accessor :file_content, :file_info, :preview_cached
|
||||||
|
|
||||||
|
@ -239,8 +239,9 @@ class Asset < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Workaround for making Paperclip work with asset deletion
|
# Workaround for making Paperclip work with asset deletion (might be because
|
||||||
def paperlip_delete
|
# of how the asset models are implemented)
|
||||||
|
def paperclip_delete
|
||||||
report_elements.destroy_all
|
report_elements.destroy_all
|
||||||
asset_text_datum.destroy if asset_text_datum.present?
|
asset_text_datum.destroy if asset_text_datum.present?
|
||||||
# Nullify needed to force paperclip file deletion
|
# Nullify needed to force paperclip file deletion
|
||||||
|
@ -248,6 +249,13 @@ class Asset < ActiveRecord::Base
|
||||||
save
|
save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
super()
|
||||||
|
# Needed, otherwise the object isn't deleted, because of how the asset
|
||||||
|
# models are implemented
|
||||||
|
delete
|
||||||
|
end
|
||||||
|
|
||||||
# If team is provided, its space_taken
|
# If team is provided, its space_taken
|
||||||
# is updated as well
|
# is updated as well
|
||||||
def update_estimated_size(team = nil)
|
def update_estimated_size(team = nil)
|
||||||
|
|
Loading…
Add table
Reference in a new issue