Sha256: 65a5b7665be37c8f55b6a728d6ecff80ceefc76c1b25430a66f3c25179c454f4

Contents?: true

Size: 1.16 KB

Versions: 58

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

module Decidim
  # The controller to manage user groups admins
  class GroupAdminsController < Decidim::ApplicationController
    include FormFactory
    include UserGroups

    before_action :enforce_user_groups_enabled

    helper_method :user_group

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

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

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

    private

    def user_group
      @user_group ||= Decidim::UserGroups::ManageableUserGroups.for(current_user).find_by(nickname: params[:group_id])
    end

    def membership
      user_group.memberships.find(params[:id])
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.27.8 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.27.7 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.27.6 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.26.10 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.26.9 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.27.5 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.26.8 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.27.4 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.27.3 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.26.7 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.26.5 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.27.2 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.27.1 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.26.4 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.27.0 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.26.3 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.27.0.rc2 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.27.0.rc1 app/controllers/decidim/group_admins_controller.rb
decidim-core-0.26.2 app/controllers/decidim/group_admins_controller.rb