mirror of
https://github.com/discourse/discourse.git
synced 2025-06-22 23:41:34 +08:00
This reverts commit b55af383f779d01d983a3ccf1149438aee9c6725.
This commit is contained in:
@ -6,33 +6,20 @@ class PostLocalizationsController < ApplicationController
|
||||
def show
|
||||
guardian.ensure_can_localize_content!
|
||||
|
||||
params.require(:post_id)
|
||||
params.require(%i[post_id])
|
||||
localizations = PostLocalization.where(post_id: params[:post_id])
|
||||
|
||||
post = Post.find_by(id: params[:post_id])
|
||||
return render json_error(I18n.t("not_found"), status: :not_found) if post.blank?
|
||||
|
||||
post_localizations = PostLocalization.where(post_id: post.id)
|
||||
|
||||
topic_localizations_by_locale = {}
|
||||
if post.is_first_post?
|
||||
TopicLocalization
|
||||
.where(topic_id: post.topic_id)
|
||||
.each { |tl| topic_localizations_by_locale[tl.locale] = tl }
|
||||
end
|
||||
|
||||
post_localizations.each do |pl|
|
||||
pl.define_singleton_method(:topic_localization) { topic_localizations_by_locale[pl.locale] }
|
||||
end
|
||||
|
||||
render json: {
|
||||
post_localizations:
|
||||
if localizations
|
||||
render json:
|
||||
ActiveModel::ArraySerializer.new(
|
||||
post_localizations,
|
||||
localizations,
|
||||
each_serializer: PostLocalizationSerializer,
|
||||
root: false,
|
||||
).as_json,
|
||||
},
|
||||
status: :ok
|
||||
status: :ok
|
||||
else
|
||||
render json_error I18n.t("not_found"), status: :not_found
|
||||
end
|
||||
end
|
||||
|
||||
def create_or_update
|
||||
|
Reference in New Issue
Block a user