Sha256: 2fd95d0a8cc87442a98925cb0112f794b7b0196c7247569cc456f421c1b9f2a8

Contents?: true

Size: 485 Bytes

Versions: 5

Compression:

Stored size: 485 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Assemblies
    # This query class filters assemblies given a current_user.
    class VisibleAssemblies < Rectify::Query
      def initialize(user)
        @user = user
      end

      def query
        assemblies = Decidim::Assembly.all

        if @user
          return assemblies if @user.admin
          assemblies.visible_for(@user.id)
        else
          assemblies.public_spaces
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-assemblies-0.17.2 app/queries/decidim/assemblies/visible_assemblies.rb
decidim-assemblies-0.17.1 app/queries/decidim/assemblies/visible_assemblies.rb
decidim-assemblies-0.16.1 app/queries/decidim/assemblies/visible_assemblies.rb
decidim-assemblies-0.17.0 app/queries/decidim/assemblies/visible_assemblies.rb
decidim-assemblies-0.16.0 app/queries/decidim/assemblies/visible_assemblies.rb