Sha256: d4f7f239cd051e356c17fbe048be87f153748be9e910248fe3cfa45959dbe3a7

Contents?: true

Size: 776 Bytes

Versions: 25

Compression:

Stored size: 776 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 groups if @current_user.admin?

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

        groups.where(id: processes.pluck(:decidim_participatory_process_group_id))
      end

      def groups
        @groups ||= Decidim::ParticipatoryProcessGroup.all
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-participatory_processes-0.26.10 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.26.9 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.26.8 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.26.7 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.26.5 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.26.4 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.26.3 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.26.2 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.26.1 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.26.0 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.26.0.rc2 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.26.0.rc1 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.25.2 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.25.1 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.25.0 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.25.0.rc4 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.25.0.rc3 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.25.0.rc2 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.25.0.rc1 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
decidim-participatory_processes-0.24.3 app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb