Allow administrators to define the cookies vendors the application uses

This commit is contained in:
taitus
2024-11-29 13:08:29 +01:00
parent 390c749d24
commit 6753505e7c
31 changed files with 375 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
class Admin::Cookies::VendorsController < Admin::BaseController
load_and_authorize_resource :vendor, class: "::Cookies::Vendor"
def create
if @vendor.save
redirect_to admin_settings_path(anchor: "tab-cookies-consent"),
notice: t("admin.cookies.vendors.create.notice")
else
render :new
end
end
def update
if @vendor.update(vendor_params)
redirect_to admin_settings_path(anchor: "tab-cookies-consent"),
notice: t("admin.cookies.vendors.update.notice")
else
render :edit
end
end
def destroy
@vendor.destroy!
redirect_to admin_settings_path(anchor: "tab-cookies-consent"),
notice: t("admin.cookies.vendors.destroy.notice")
end
private
def vendor_params
params.require(:cookies_vendor).permit(allowed_params)
end
def allowed_params
[:name, :description, :cookie, :script]
end
end