Sha256: d3f6dfa6b081b0b8cbf7ab3a66b001975cbf05dd5cc28da0ec1dd3d378729d14

Contents?: true

Size: 718 Bytes

Versions: 5

Compression:

Stored size: 718 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module ParticipatoryProcesses
    # This query class filters participatory processes given a current_user.
    class VisibleParticipatoryProcessGroups < Rectify::Query
      def initialize(current_user)
        @current_user = current_user
      end

      def query
        processes = Decidim::ParticipatoryProcess.all

        if @current_user
          return processes if @current_user.admin
          processes = processes.visible_for(@current_user.id)
        else
          processes = processes.public_spaces
        end

        Decidim::ParticipatoryProcessGroup.where(id: processes.pluck(:decidim_participatory_process_group_id))
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-participatory_processes-0.18.1 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.17.2 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.18.0 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.17.1 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.17.0 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb