Sha256: 4dda2a8f1247b57da1f2214d52ecbc1d53cc5969113619032fbdd79310becf6a

Contents?: true

Size: 1.28 KB

Versions: 11

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

module Decidim
  module DecidimAwesome
    module Admin
      # Global configuration controller
      class ScopedAdminsController < DecidimAwesome::Admin::ConfigController
        def create
          CreateScopedAdmin.call(current_organization) do
            on(:ok) do |key|
              flash[:notice] = I18n.t("config.create_scoped_admin.success", key: key, scope: "decidim.decidim_awesome.admin")
            end

            on(:invalid) do |message|
              flash[:alert] = I18n.t("config.create_scoped_admin.error", error: message, scope: "decidim.decidim_awesome.admin")
            end
          end

          redirect_to decidim_admin_decidim_awesome.config_path(:admins)
        end

        def destroy
          DestroyScopedAdmin.call(params[:key], current_organization) do
            on(:ok) do |key|
              flash[:notice] = I18n.t("config.destroy_scoped_admin.success", key: key, scope: "decidim.decidim_awesome.admin")
            end

            on(:invalid) do |message|
              flash[:alert] = I18n.t("config.destroy_scoped_admin.error", error: message, scope: "decidim.decidim_awesome.admin")
            end
          end

          redirect_to decidim_admin_decidim_awesome.config_path(:admins)
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
decidim-decidim_awesome-0.10.3 app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb
decidim-decidim_awesome-0.10.2 app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb
decidim-decidim_awesome-0.10.1 app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb
decidim-decidim_awesome-0.10.0 app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb
decidim-decidim_awesome-0.9.3 app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb
decidim-decidim_awesome-0.9.1 app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb
decidim-decidim_awesome-0.8.3 app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb
decidim-decidim_awesome-0.8.2 app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb
decidim-decidim_awesome-0.8.1 app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb
decidim-decidim_awesome-0.8.0 app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb
decidim-decidim_awesome-0.7.2 app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb