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 UserBlockedChecker

#check_user_block_status, #check_user_not_blocked

Methods included from NeedsSnippets

#snippets

Methods included from Headers::HttpCachingDisabler

#disable_http_caching

Methods included from HasStoredPath

#skip_store_location?, #store_current_location

Methods included from TranslatableAttributes

#default_locale?

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#demoteObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/controllers/decidim/group_members_controller.rb', line 48

def demote
  enforce_permission_to(:manage, :user_group, user_group:)

  DemoteMembership.call(membership, user_group) do
    on(:ok) do
      flash[:notice] = t("group_admins.demote.success", scope: "decidim")

      redirect_back fallback_location: profile_group_admins_path(user_group.nickname)
    end

    on(:invalid) do
      flash[:alert] = t("group_admins.demote.error", scope: "decidim")
      redirect_back fallback_location: profile_group_admins_path(user_group.nickname)
    end
  end
end

#destroyObject

Removes a user from a user group



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/decidim/group_members_controller.rb', line 14

def destroy
  enforce_permission_to(:manage, :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: profile_group_members_path(user_group.nickname)
    end

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

#promoteObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/decidim/group_members_controller.rb', line 31

def promote
  enforce_permission_to(:manage, :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: profile_group_members_path(user_group.nickname)
    end

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