Class: Decidim::Admin::OfficializationsController

Inherits:
ApplicationController show all
Includes:
Decidim::Admin::Officializations::Filterable
Defined in:
decidim-admin/app/controllers/decidim/admin/officializations_controller.rb

Overview

Controller that allows managing user officializations 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

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


26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'decidim-admin/app/controllers/decidim/admin/officializations_controller.rb', line 26

def create
  enforce_permission_to :create, :officialization

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

  OfficializeUser.call(@form) do
    on(:ok) do |user|
      notice = I18n.t("officializations.create.success", scope: "decidim.admin")

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

#destroyObject


40
41
42
43
44
45
46
47
48
49
50
# File 'decidim-admin/app/controllers/decidim/admin/officializations_controller.rb', line 40

def destroy
  enforce_permission_to :destroy, :officialization

  UnofficializeUser.call(user, current_user) do
    on(:ok) do
      notice = I18n.t("officializations.destroy.success", scope: "decidim.admin")

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

#indexObject


15
16
17
18
# File 'decidim-admin/app/controllers/decidim/admin/officializations_controller.rb', line 15

def index
  enforce_permission_to :read, :officialization
  @users = filtered_collection
end

#newObject


20
21
22
23
24
# File 'decidim-admin/app/controllers/decidim/admin/officializations_controller.rb', line 20

def new
  enforce_permission_to :create, :officialization

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

#show_emailObject


52
53
54
55
56
57
58
# File 'decidim-admin/app/controllers/decidim/admin/officializations_controller.rb', line 52

def show_email
  enforce_permission_to :show_email, :user, user: user

  Decidim.traceability.perform_action! :show_email, user, current_user

  render :show_email, layout: false
end