2015-08-18 17:15:46 -04:00
|
|
|
class Admin::EmbeddableHostsController < Admin::AdminController
|
|
|
|
|
|
|
|
before_filter :ensure_logged_in, :ensure_staff
|
|
|
|
|
|
|
|
def create
|
|
|
|
save_host(EmbeddableHost.new)
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
host = EmbeddableHost.where(id: params[:id]).first
|
|
|
|
save_host(host)
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
host = EmbeddableHost.where(id: params[:id]).first
|
|
|
|
host.destroy
|
|
|
|
render json: success_json
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def save_host(host)
|
|
|
|
host.host = params[:embeddable_host][:host]
|
2016-08-23 14:55:52 -04:00
|
|
|
host.path_whitelist = params[:embeddable_host][:path_whitelist]
|
2017-05-05 18:08:18 -04:00
|
|
|
host.class_name = params[:embeddable_host][:class_name]
|
2015-08-18 17:15:46 -04:00
|
|
|
host.category_id = params[:embeddable_host][:category_id]
|
|
|
|
host.category_id = SiteSetting.uncategorized_category_id if host.category_id.blank?
|
|
|
|
|
|
|
|
if host.save
|
|
|
|
render_serialized(host, EmbeddableHostSerializer, root: 'embeddable_host', rest_serializer: true)
|
|
|
|
else
|
|
|
|
render_json_error(host)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|