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 Headers::HttpCachingDisabler

#disable_http_caching

Methods included from TranslatableAttributes

#default_locale?

Methods included from NeedsSnippets

#snippets

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#createObject



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

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:
    end
  end
end

#destroyObject



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

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:
    end
  end
end

#indexObject



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

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

#newObject



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

def new
  enforce_permission_to :create, :officialization

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

#show_emailObject



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

def show_email
  enforce_permission_to(:show_email, :user, user:)

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

  render :show_email, layout: false
end