Class: Decidim::DecidimAwesome::Admin::ScopedAdminsController

Inherits:
ConfigController show all
Defined in:
app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb

Overview

Global configuration controller

Constant Summary

Constants included from ConfigConstraintsHelpers

ConfigConstraintsHelpers::OTHER_MANIFESTS

Instance Method Summary collapse

Methods inherited from ConfigController

#rename_scope_label, #show, #update, #users

Methods included from ConfigConstraintsHelpers

#check, #component_manifests, #components_list, #enabled_configs, #md5, #participatory_space_manifests, #participatory_spaces_list, #translate_constraint_value

Methods included from NeedsAwesomeConfig

extended, included

Methods inherited from ApplicationController

#permission_class_chain

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb', line 8

def create
  CreateScopedAdmin.call(current_organization) do
    on(:ok) do |key|
      flash[:notice] = I18n.t("config.create_scoped_admin.success", 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

#destroyObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb', line 22

def destroy
  DestroyScopedAdmin.call(params[:key], current_organization) do
    on(:ok) do |key|
      flash[:notice] = I18n.t("config.destroy_scoped_admin.success", 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