このコミットが含まれているのは:
@@ -14,7 +14,7 @@ class TagDescriptionsController < ApplicationController
|
||||
render json: representation(description)
|
||||
end
|
||||
|
||||
def create
|
||||
def update
|
||||
return head :unauthorized unless current_user
|
||||
return head :forbidden unless current_user.gte_member?
|
||||
|
||||
@@ -24,39 +24,23 @@ class TagDescriptionsController < ApplicationController
|
||||
tag = Tag.find_by(id: params[:id])
|
||||
return head :not_found unless tag
|
||||
|
||||
if TagDescription.exists?(tag:, language_code: 'ja')
|
||||
return render_unprocessable_entity('説明はすでに存在します.')
|
||||
description = TagDescription.find_by(tag:, language_code: 'ja')
|
||||
|
||||
if description
|
||||
TagDescriptionOperation.update!(tag:, body:, updated_by_user: current_user)
|
||||
description.reload
|
||||
render json: representation(description)
|
||||
else
|
||||
TagDescriptionOperation.create!(tag:, body:, created_by_user: current_user)
|
||||
description = TagDescription.find_by!(tag:, language_code: 'ja')
|
||||
render json: representation(description), status: :created
|
||||
end
|
||||
|
||||
TagDescriptionOperation.create!(tag:, body:, created_by_user: current_user)
|
||||
description = TagDescription.find_by!(tag:, language_code: 'ja')
|
||||
|
||||
render json: representation(description), status: :created
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
render_validation_error e.record
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
render_record_not_unique
|
||||
end
|
||||
|
||||
def update
|
||||
return head :unauthorized unless current_user
|
||||
return head :forbidden unless current_user.gte_member?
|
||||
|
||||
body = params[:body].to_s
|
||||
return render_unprocessable_entity('本文は必須です.', field: :body) if body.blank?
|
||||
|
||||
description = TagDescription.find_by(tag_id: params[:id], language_code: 'ja')
|
||||
return create unless description
|
||||
|
||||
TagDescriptionOperation.update!(
|
||||
tag: description.tag, body:, updated_by_user: current_user)
|
||||
description.reload
|
||||
|
||||
render json: representation(description)
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
render_validation_error e.record
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def representation description
|
||||
|
||||
@@ -2,6 +2,10 @@ class WikiPagesController < ApplicationController
|
||||
rescue_from Wiki::Commit::Conflict, with: :render_wiki_conflict
|
||||
|
||||
def index
|
||||
# 互換性のための化石リソース
|
||||
# TODO: ヘルプおよびタグ・グループ追加後に,
|
||||
# TODO: タグ説明とヘルプ、タグ・グループから取得する作りに変更する.
|
||||
#
|
||||
title = params[:title].to_s.strip
|
||||
descriptions = TagDescription.where(language_code: 'ja')
|
||||
.includes(tag: :tag_names)
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする