Class: Decidim::Admin::BlockUserController

Inherits:
ApplicationController show all
Defined in:
decidim-admin/app/controllers/decidim/admin/block_user_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from NeedsSnippets

#snippets

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#createObject


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

def create
  enforce_permission_to :block, :admin_user

  @form = form(BlockUserForm).from_params(params)

  BlockUser.call(@form) do
    on(:ok) do
      flash[:notice] = I18n.t("officializations.block.success", scope: "decidim.admin")
      redirect_to officializations_path(q: { name_or_nickname_or_email_cont: user.name }), notice: notice
    end

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

#destroyObject


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'decidim-admin/app/controllers/decidim/admin/block_user_controller.rb', line 34

def destroy
  enforce_permission_to :block, :admin_user

  UnblockUser.call(user, current_user) do
    on(:ok) do
      flash[:notice] = I18n.t("officializations.unblock.success", scope: "decidim.admin")
    end

    on(:invalid) do
      flash[:alert] = I18n.t("officializations.unblock.error", scope: "decidim.admin")
    end
  end

  redirect_to officializations_path(q: { name_or_nickname_or_email_cont: user.name }), notice: notice
end

#newObject


10
11
12
13
14
# File 'decidim-admin/app/controllers/decidim/admin/block_user_controller.rb', line 10

def new
  enforce_permission_to :block, :admin_user

  @form = form(BlockUserForm).from_model(user)
end