Class: Decidim::Admin::UserGroupsController

Inherits:
ApplicationController show all
Includes:
UserGroups, Decidim::Admin::UserGroups::Filterable
Defined in:
app/controllers/decidim/admin/user_groups_controller.rb

Overview

Controller that allows managing user groups at the admin panel.

Instance Method Summary collapse

Methods included from UserGroups

#enforce_user_groups_enabled

Methods inherited from ApplicationController

#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path

Instance Method Details

#indexObject



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

def index
  enforce_permission_to :index, :user_group

  @user_groups = filtered_collection
end

#rejectObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/controllers/decidim/admin/user_groups_controller.rb', line 38

def reject
  @user_group = collection.find(params[:id])
  enforce_permission_to :reject, :user_group, user_group: @user_group

  RejectUserGroup.call(@user_group, current_user) do
    on(:ok) do
      flash[:notice] = I18n.t("user_group.reject.success", scope: "decidim.admin")
      redirect_back(fallback_location: decidim_admin.user_groups_path)
    end

    on(:invalid) do
      flash[:alert] = I18n.t("user_group.reject.invalid", scope: "decidim.admin")
      redirect_back(fallback_location: decidim_admin.user_groups_path)
    end
  end
end

#verifyObject



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

def verify
  @user_group = collection.find(params[:id])
  enforce_permission_to :verify, :user_group, user_group: @user_group

  VerifyUserGroup.call(@user_group, current_user) do
    on(:ok) do
      flash[:notice] = I18n.t("user_group.verify.success", scope: "decidim.admin")
      redirect_back(fallback_location: decidim_admin.user_groups_path)
    end

    on(:invalid) do
      flash[:alert] = I18n.t("user_group.verify.invalid", scope: "decidim.admin")
      redirect_back(fallback_location: decidim_admin.user_groups_path)
    end
  end
end