Sha256: cc8de37fde433a4bb5292a970c27ea3b5447ef390ed689ed9ac02a2f0b1f476b
Contents?: true
Size: 1.61 KB
Versions: 14
Compression:
Stored size: 1.61 KB
Contents
# frozen_string_literal: true require_dependency "decidim/system/application_controller" module Decidim module System # Controller that allows managing all the Admins. # class AdminsController < ApplicationController def index @admins = Admin.all end def new @form = AdminForm.new end def create @form = AdminForm.from_params(params) CreateAdmin.call(@form) do on(:ok) do flash[:notice] = I18n.t("admins.create.success", scope: "decidim.system") redirect_to admins_path end on(:invalid) do flash.now[:alert] = I18n.t("admins.create.error", scope: "decidim.system") render :new end end end def edit @admin = Admin.find(params[:id]) @form = AdminForm.from_model(@admin) end def update @admin = Admin.find(params[:id]) @form = AdminForm.from_params(params) UpdateAdmin.call(@admin, @form) do on(:ok) do flash[:notice] = I18n.t("admins.update.success", scope: "decidim.system") redirect_to admins_path end on(:invalid) do flash.now[:alert] = I18n.t("admins.update.error", scope: "decidim.system") render :edit end end end def show @admin = Admin.find(params[:id]) end def destroy @admin = Admin.find(params[:id]).destroy! flash[:notice] = I18n.t("admins.destroy.success", scope: "decidim.system") redirect_to admins_path end end end end
Version data entries
14 entries across 14 versions & 2 rubygems