Sha256: ae5022715a540052a9db4aed23a77d0590d065856f6b4deb16f9d8c872caf0b3

Contents?: true

Size: 733 Bytes

Versions: 6

Compression:

Stored size: 733 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # This cell is intended to be used on profiles.
  # Lists the pending join requests of the given user group.
  class UserGroupPendingRequestsListCell < Decidim::ViewModel
    include Decidim::CellsPaginateHelper
    include Decidim::Core::Engine.routes.url_helpers
    include Decidim::CardHelper

    def show
      return if requests.empty?
      return unless current_user_is_manager?

      render :show
    end

    def requests
      @requests ||= Decidim::UserGroupMembership.includes(:user).where(user_group: model, role: "requested")
    end

    def current_user_is_manager?
      Decidim::UserGroups::ManageableUserGroups.for(current_user).include?(model)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/cells/decidim/user_group_pending_requests_list_cell.rb
decidim-core-0.29.0 app/cells/decidim/user_group_pending_requests_list_cell.rb
decidim-core-0.29.0.rc4 app/cells/decidim/user_group_pending_requests_list_cell.rb
decidim-core-0.29.0.rc3 app/cells/decidim/user_group_pending_requests_list_cell.rb
decidim-core-0.29.0.rc2 app/cells/decidim/user_group_pending_requests_list_cell.rb
decidim-core-0.29.0.rc1 app/cells/decidim/user_group_pending_requests_list_cell.rb