Sha256: fa1fed63a9a24c9dc88bb49704e8064a51a62d62c8f439e72cd079265e4b8f2a

Contents?: true

Size: 719 Bytes

Versions: 14

Compression:

Stored size: 719 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

14 entries across 14 versions & 1 rubygems

Version Path
decidim-participatory_processes-0.23.6 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.23.5 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.23.4 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.23.3 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.23.2 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.23.1 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.23.1.rc1 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.23.0 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.22.0 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.21.0 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.20.1 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.20.0 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.19.1 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.19.0 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb