2019-05-02 01:57:12 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-08-18 16:15:46 -05:00
|
|
|
class Admin::EmbeddingController < Admin::AdminController
|
2018-01-31 19:26:45 -06:00
|
|
|
before_action :fetch_embedding
|
2015-08-18 16:15:46 -05:00
|
|
|
|
|
|
|
def show
|
2023-01-09 06:20:10 -06:00
|
|
|
render_serialized(@embedding, EmbeddingSerializer, root: "embedding", rest_serializer: true)
|
2015-08-18 16:15:46 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2015-10-13 15:33:26 -05:00
|
|
|
if params[:embedding][:embed_by_username].blank?
|
2023-01-09 06:20:10 -06:00
|
|
|
return render_json_error(I18n.t("site_settings.embed_username_required"))
|
2015-10-13 15:33:26 -05:00
|
|
|
end
|
|
|
|
|
2023-01-09 06:20:10 -06:00
|
|
|
Embedding.settings.each { |s| @embedding.public_send("#{s}=", params[:embedding][s]) }
|
2015-08-20 12:43:12 -05:00
|
|
|
|
|
|
|
if @embedding.save
|
|
|
|
fetch_embedding
|
2023-01-09 06:20:10 -06:00
|
|
|
render_serialized(@embedding, EmbeddingSerializer, root: "embedding", rest_serializer: true)
|
2015-08-20 12:43:12 -05:00
|
|
|
else
|
|
|
|
render_json_error(@embedding)
|
|
|
|
end
|
2015-08-18 16:15:46 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
2018-06-07 00:28:18 -05:00
|
|
|
def fetch_embedding
|
|
|
|
@embedding = Embedding.find
|
|
|
|
end
|
2015-08-18 16:15:46 -05:00
|
|
|
end
|