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