Sha256: 535687c226ba7a9d17b56ab351d5a33c9a2f0ec41f8aae43127fdc0b3069f7cb
Contents?: true
Size: 1.64 KB
Versions: 14
Compression:
Stored size: 1.64 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 = form(AdminForm).instance end def create @form = 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 = form(AdminForm).from_model(@admin) end def update @admin = Admin.find(params[:id]) @form = 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