このコミットが含まれているのは:
@@ -48,9 +48,8 @@ class TagDescriptionsController < ApplicationController
|
|||||||
description = TagDescription.find_by(tag_id: params[:id], language_code: 'ja')
|
description = TagDescription.find_by(tag_id: params[:id], language_code: 'ja')
|
||||||
return head :not_found unless description
|
return head :not_found unless description
|
||||||
|
|
||||||
page = WikiPage.find(description.id)
|
|
||||||
TagDescriptionOperation.update!(
|
TagDescriptionOperation.update!(
|
||||||
description:, page:, body:, updated_by_user: current_user)
|
tag: description.tag, body:, updated_by_user: current_user)
|
||||||
description.reload
|
description.reload
|
||||||
|
|
||||||
render json: representation(description)
|
render json: representation(description)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class TagDescriptionOperation
|
|||||||
raise ActiveRecord::RecordNotUnique if TagDescription.exists?(
|
raise ActiveRecord::RecordNotUnique if TagDescription.exists?(
|
||||||
tag_id: tag.id, language_code: LANGUAGE_CODE)
|
tag_id: tag.id, language_code: LANGUAGE_CODE)
|
||||||
|
|
||||||
page = Wiki::Commit.create_legacy_content!(
|
page = Wiki::CompatibilityWriter.create!(
|
||||||
tag_name: tag.tag_name(LANGUAGE_CODE), body:, created_by_user:, message:)
|
tag_name: tag.tag_name(LANGUAGE_CODE), body:, created_by_user:, message:)
|
||||||
revision = page.wiki_revisions.order(id: :desc).first
|
revision = page.wiki_revisions.order(id: :desc).first
|
||||||
record_version!(tag:, revision:, body:, user: created_by_user,
|
record_version!(tag:, revision:, body:, user: created_by_user,
|
||||||
@@ -16,18 +16,23 @@ class TagDescriptionOperation
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.update!(description:, page:, body:, updated_by_user:, message: nil,
|
def self.update!(tag:, body:, updated_by_user:, message: nil,
|
||||||
base_revision_id: nil)
|
base_revision_id: nil)
|
||||||
ApplicationRecord.transaction do
|
ApplicationRecord.transaction do
|
||||||
|
tag.lock!
|
||||||
|
description = TagDescription.lock.find_by(
|
||||||
|
tag_id: tag.id, language_code: LANGUAGE_CODE)
|
||||||
description&.lock!
|
description&.lock!
|
||||||
page.lock!
|
tag_name = tag.tag_name(LANGUAGE_CODE)
|
||||||
revision = Wiki::Commit.legacy_content!(
|
page = WikiPage.lock.find_by!(tag_name:)
|
||||||
page:, body:, created_user: updated_by_user, message:,
|
revision = Wiki::CompatibilityWriter.update!(
|
||||||
|
page:, body:, updated_by_user:, message:,
|
||||||
base_revision_id:)
|
base_revision_id:)
|
||||||
record_version!(tag: page.tag_name.tag, revision:, body: revision.body,
|
next unless revision
|
||||||
|
|
||||||
|
record_version!(tag:, revision:, body: revision.body,
|
||||||
user: updated_by_user, description:)
|
user: updated_by_user, description:)
|
||||||
description || TagDescription.find_by!(
|
revision
|
||||||
tag_id: page.tag_name.tag_id, language_code: LANGUAGE_CODE)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -43,11 +43,9 @@ module Wiki
|
|||||||
|
|
||||||
def self.content! page:, body:, created_user:, message: nil, base_revision_id: nil
|
def self.content! page:, body:, created_user:, message: nil, base_revision_id: nil
|
||||||
tag = page.tag_name.tag
|
tag = page.tag_name.tag
|
||||||
description = tag && page.tag_name.language_code == 'ja' &&
|
|
||||||
TagDescription.find_by(tag_id: tag.id, language_code: 'ja')
|
|
||||||
if tag && page.tag_name.language_code == 'ja'
|
if tag && page.tag_name.language_code == 'ja'
|
||||||
return TagDescriptionOperation.update!(
|
return TagDescriptionOperation.update!(
|
||||||
description:, page:, body:, updated_by_user: created_user,
|
tag:, body:, updated_by_user: created_user,
|
||||||
message:, base_revision_id:)
|
message:, base_revision_id:)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
module Wiki
|
||||||
|
class CompatibilityWriter
|
||||||
|
def self.create! tag_name:, body:, created_by_user:, message: nil
|
||||||
|
Commit.create_legacy_content!(
|
||||||
|
tag_name:, body:, created_by_user:, message:)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.update! page:, body:, updated_by_user:, message: nil,
|
||||||
|
base_revision_id: nil
|
||||||
|
normalised = Commit.normalise_body(body)
|
||||||
|
if normalised.blank?
|
||||||
|
return Commit.legacy_content!(
|
||||||
|
page:, body: normalised, created_user: updated_by_user, message:,
|
||||||
|
base_revision_id:)
|
||||||
|
end
|
||||||
|
|
||||||
|
if base_revision_id.present?
|
||||||
|
current_id = page.wiki_revisions.maximum(:id)
|
||||||
|
if current_id && current_id != base_revision_id.to_i
|
||||||
|
raise Commit::Conflict,
|
||||||
|
"競合が発生してゐます" +
|
||||||
|
"(現在の Id.:#{ current_id },ベース Id.:#{ base_revision_id })."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return if Commit.normalise_body(page.body) == normalised
|
||||||
|
|
||||||
|
Commit.legacy_content!(
|
||||||
|
page:, body: normalised, created_user: updated_by_user, message:,
|
||||||
|
base_revision_id:)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
新しいイシューから参照
ユーザーをブロックする