Sha256: 9837a363af5dc0936e83aee18ff9bdc2026ea9ee7c7da305bee3fae1136ca374

Contents?: true

Size: 1.04 KB

Versions: 13

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Decidim
  module Sortitions
    # Exposes the sortition resource so users can view them
    class SortitionsController < Decidim::Sortitions::ApplicationController
      include FilterResource
      include Decidim::Sortitions::Orderable
      include Paginable

      helper_method :sortition

      helper Decidim::Proposals::ApplicationHelper

      def index
        @sortitions = search
                      .result
                      .includes(:category)

        @sortitions = reorder(@sortitions)
        @sortitions = paginate(@sortitions)
      end

      def show
        raise ActionController::RoutingError, "Not Found" unless sortition
      end

      private

      def sortition
        search_collection.find_by(id: params[:id])
      end

      def search_collection
        Sortition.where(component: current_component)
      end

      def default_filter_params
        {
          search_text_cont: "",
          with_category: "",
          with_any_state: "active"
        }
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-sortitions-0.29.1 app/controllers/decidim/sortitions/sortitions_controller.rb
decidim-sortitions-0.28.4 app/controllers/decidim/sortitions/sortitions_controller.rb
decidim-sortitions-0.29.0 app/controllers/decidim/sortitions/sortitions_controller.rb
decidim-sortitions-0.28.3 app/controllers/decidim/sortitions/sortitions_controller.rb
decidim-sortitions-0.29.0.rc4 app/controllers/decidim/sortitions/sortitions_controller.rb
decidim-sortitions-0.29.0.rc3 app/controllers/decidim/sortitions/sortitions_controller.rb
decidim-sortitions-0.29.0.rc2 app/controllers/decidim/sortitions/sortitions_controller.rb
decidim-sortitions-0.29.0.rc1 app/controllers/decidim/sortitions/sortitions_controller.rb
decidim-sortitions-0.28.2 app/controllers/decidim/sortitions/sortitions_controller.rb
decidim-sortitions-0.28.1 app/controllers/decidim/sortitions/sortitions_controller.rb
decidim-sortitions-0.28.0 app/controllers/decidim/sortitions/sortitions_controller.rb
decidim-sortitions-0.28.0.rc5 app/controllers/decidim/sortitions/sortitions_controller.rb
decidim-sortitions-0.28.0.rc4 app/controllers/decidim/sortitions/sortitions_controller.rb