Sha256: ff4716ee9374023883043c03cd234f6fa10923d8daef23dff62dcaf55a1abbf8

Contents?: true

Size: 578 Bytes

Versions: 5

Compression:

Stored size: 578 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module ParticipatoryProcesses
    # This query class filters participatory processes given a current_user.
    class VisibleParticipatoryProcesses < 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.visible_for(@current_user.id)
        else
          processes.public_spaces
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-participatory_processes-0.17.2 app/queries/decidim/participatory_processes/visible_participatory_processes.rb
decidim-participatory_processes-0.17.1 app/queries/decidim/participatory_processes/visible_participatory_processes.rb
decidim-participatory_processes-0.16.1 app/queries/decidim/participatory_processes/visible_participatory_processes.rb
decidim-participatory_processes-0.17.0 app/queries/decidim/participatory_processes/visible_participatory_processes.rb
decidim-participatory_processes-0.16.0 app/queries/decidim/participatory_processes/visible_participatory_processes.rb