Class: Decidim::Admin::UserGroupsController

Inherits:
ApplicationController show all
Includes:
UserGroups
Defined in:
decidim-admin/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

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

#indexObject


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

def index
  enforce_permission_to :index, :user_group
  @query = params[:q]
  @state = params[:state]

  @user_groups = Decidim::Admin::UserGroupsEvaluation.for(collection, @query, @state)
                                                     .page(params[:page]).per(15)
end

#rejectObject


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

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


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

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