mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
disable changelogs for attribute migration
This commit is contained in:
parent
27dfba432a
commit
2a1a3e20d8
@ -270,21 +270,30 @@ class ContentController < ApplicationController
|
||||
|
||||
unless attribute_value.nil?
|
||||
if existing_value
|
||||
existing_value.disable_changelog_this_request = true
|
||||
existing_value.update!(value: attribute_value)
|
||||
existing_value.disable_changelog_this_request = false
|
||||
else
|
||||
attribute_field.attribute_values.create!(
|
||||
new_value = attribute_field.attribute_values.new(
|
||||
user_id: current_user.id,
|
||||
entity_type: @content.class.name,
|
||||
entity_id: @content.id,
|
||||
value: attribute_value,
|
||||
privacy: 'private' # todo just make this the default for the column instead
|
||||
)
|
||||
|
||||
new_value.disable_changelog_this_request = true
|
||||
new_value.save!
|
||||
new_value.disable_changelog_this_request = true
|
||||
end
|
||||
end
|
||||
|
||||
if delete_model_source_value && attribute_field.old_column_source.present? && attribute_field.field_type != 'name' && @content.send(attribute_field.old_column_source).present?
|
||||
@content.update_attribute(attribute_field.old_column_source, nil)
|
||||
end
|
||||
# Lets leave these columns alone for now so 1) we don't have to mess with disabling changelogs, and 2) why not be safe?
|
||||
# if delete_model_source_value && attribute_field.old_column_source.present? && attribute_field.field_type != 'name' && @content.send(attribute_field.old_column_source).present?
|
||||
# @content.disable_changelog_this_request = true
|
||||
# @content.update_attribute(attribute_field.old_column_source, nil)
|
||||
# @content.disable_changelog_this_request = false
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ module HasAttributes
|
||||
user: user,
|
||||
field_type: field[:field_type].presence || "text_area"
|
||||
)
|
||||
af_field.save! if user
|
||||
af_field.save if user
|
||||
af_field
|
||||
end if details.key?(:attributes)
|
||||
|
||||
|
||||
@ -4,6 +4,8 @@ module HasChangelog
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
attr_accessor :disable_changelog_this_request
|
||||
|
||||
def content_change_events
|
||||
ContentChangeEvent.where(
|
||||
content_id: id,
|
||||
@ -28,7 +30,7 @@ module HasChangelog
|
||||
content_id: id,
|
||||
content_type: self.class.name,
|
||||
action: :created
|
||||
) if changes.any?
|
||||
) if changes.any? && !!disable_changelog_this_request
|
||||
end
|
||||
|
||||
before_update do
|
||||
@ -39,7 +41,7 @@ module HasChangelog
|
||||
content_id: id,
|
||||
content_type: self.class.name,
|
||||
action: :updated
|
||||
) if changes.any?
|
||||
) if changes.any? && !!disable_changelog_this_request
|
||||
end
|
||||
|
||||
before_destroy do
|
||||
@ -49,7 +51,7 @@ module HasChangelog
|
||||
content_id: id,
|
||||
content_type: self.class.name,
|
||||
action: :deleted
|
||||
)
|
||||
) if !!disable_changelog_this_request
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Loading…
Reference in New Issue
Block a user