Class: Decidim::Admin::ManagedUsers::PromotionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/decidim/admin/managed_users/promotions_controller.rb

Overview

Controller that allows promoting managed users at the admin panel.

Instance Method Summary collapse

Methods inherited from ApplicationController

#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/decidim/admin/managed_users/promotions_controller.rb', line 16

def create
  enforce_permission_to :promote, :managed_user, user: user
  @form = form(ManagedUserPromotionForm).from_params(params)

  PromoteManagedUser.call(@form, user, current_user) do
    on(:ok) do
      flash[:notice] = I18n.t("managed_users.promotion.success", scope: "decidim.admin")
      redirect_to impersonatable_users_path
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("managed_users.promotion.error", scope: "decidim.admin")
      render :new
    end
  end
end

#newObject



11
12
13
14
# File 'app/controllers/decidim/admin/managed_users/promotions_controller.rb', line 11

def new
  enforce_permission_to :promote, :managed_user, user: user
  @form = form(ManagedUserPromotionForm).instance
end