2013-02-05 14:16:51 -05:00
|
|
|
class Admin::SiteCustomizationsController < Admin::AdminController
|
2013-02-07 10:45:24 -05:00
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
def index
|
|
|
|
@site_customizations = SiteCustomization.all
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.json { render json: @site_customizations }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2013-06-06 03:14:32 -04:00
|
|
|
@site_customization = SiteCustomization.new(site_customization_params)
|
2013-02-05 14:16:51 -05:00
|
|
|
@site_customization.user_id = current_user.id
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
if @site_customization.save
|
2013-08-21 10:49:35 -04:00
|
|
|
log_site_customization_change(nil, site_customization_params)
|
2013-02-05 14:16:51 -05:00
|
|
|
format.json { render json: @site_customization, status: :created}
|
|
|
|
else
|
|
|
|
format.json { render json: @site_customization.errors, status: :unprocessable_entity }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@site_customization = SiteCustomization.find(params[:id])
|
2013-08-21 10:49:35 -04:00
|
|
|
log_record = log_site_customization_change(@site_customization, site_customization_params)
|
2013-02-05 14:16:51 -05:00
|
|
|
|
|
|
|
respond_to do |format|
|
2013-06-06 03:14:32 -04:00
|
|
|
if @site_customization.update_attributes(site_customization_params)
|
2013-02-05 14:16:51 -05:00
|
|
|
format.json { head :no_content }
|
|
|
|
else
|
2013-08-21 10:49:35 -04:00
|
|
|
log_record.destroy if log_record
|
2013-02-05 14:16:51 -05:00
|
|
|
format.json { render json: @site_customization.errors, status: :unprocessable_entity }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@site_customization = SiteCustomization.find(params[:id])
|
2013-08-21 12:03:21 -04:00
|
|
|
StaffActionLogger.new(current_user).log_site_customization_destroy(@site_customization)
|
2013-02-05 14:16:51 -05:00
|
|
|
@site_customization.destroy
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.json { head :no_content }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-06 03:14:32 -04:00
|
|
|
private
|
|
|
|
|
|
|
|
def site_customization_params
|
2013-09-16 12:21:49 -04:00
|
|
|
params.require(:site_customization).permit(:name, :stylesheet, :header, :mobile_stylesheet, :mobile_header, :position, :enabled, :key, :override_default_style, :stylesheet_baked)
|
2013-06-06 03:14:32 -04:00
|
|
|
end
|
|
|
|
|
2013-08-21 10:49:35 -04:00
|
|
|
def log_site_customization_change(old_record, new_params)
|
|
|
|
StaffActionLogger.new(current_user).log_site_customization_change(old_record, new_params)
|
|
|
|
end
|
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|