Class: Decidim::GroupMembersController

Inherits:
ApplicationController show all
Includes:
FormFactory, UserGroups
Defined in:
app/controllers/decidim/group_members_controller.rb

Overview

The controller to manage user groups members

Instance Method Summary collapse

Methods included from UserGroups

#enforce_user_groups_enabled

Methods included from NeedsSnippets

#snippets

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#destroyObject

Removes a user from a user group



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/decidim/group_members_controller.rb', line 18

def destroy
  enforce_permission_to :manage, :user_group, user_group: user_group

  RemoveUserFromGroup.call(membership, user_group) do
    on(:ok) do
      flash[:notice] = t("group_members.remove.success", scope: "decidim")

      redirect_back fallback_location: group_manage_users_path(user_group.nickname)
    end

    on(:invalid) do
      flash[:alert] = t("group_members.remove.error", scope: "decidim")
      redirect_back fallback_location: group_manage_users_path(user_group.nickname)
    end
  end
end

#indexObject



13
14
15
# File 'app/controllers/decidim/group_members_controller.rb', line 13

def index
  enforce_permission_to :manage, :user_group, user_group: user_group
end

#promoteObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/decidim/group_members_controller.rb', line 35

def promote
  enforce_permission_to :manage, :user_group, user_group: user_group

  PromoteMembership.call(membership, user_group) do
    on(:ok) do
      flash[:notice] = t("group_members.promote.success", scope: "decidim")

      redirect_back fallback_location: group_manage_users_path(user_group.nickname)
    end

    on(:invalid) do
      flash[:alert] = t("group_members.promote.error", scope: "decidim")
      redirect_back fallback_location: group_manage_users_path(user_group.nickname)
    end
  end
end