Sha256: 516ac7b1ec3d4bec5fff1971de8ce9720ac8538dc1e40416653a3415d215dd30

Contents?: true

Size: 991 Bytes

Versions: 8

Compression:

Stored size: 991 Bytes

Contents

# frozen_string_literal: true

require "active_support/concern"

module Decidim
  # This module, when injected into a controller, ensures there's a
  # Participatory Process available and deducts it from the context.
  module NeedsParticipatoryProcess
    extend ActiveSupport::Concern

    include NeedsOrganization

    included do
      after_action :verify_participatory_process
      helper_method :current_participatory_process

      # Public: Finds the current Participatory Process given this controller's
      # context.
      #
      # Returns the current ParticipatoryProcess.
      def current_participatory_process
        @current_participatory_process ||= current_organization.participatory_processes.find_by(id: params[:participatory_process_id] || params[:id])
      end

      private

      def verify_participatory_process
        raise ActionController::RoutingError, "Participatory process not found." unless current_participatory_process
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
decidim-core-0.2.0 app/controllers/concerns/decidim/needs_participatory_process.rb
decidim-core-0.1.0 app/controllers/concerns/decidim/needs_participatory_process.rb
decidim-core-0.0.8.1 app/controllers/concerns/decidim/needs_participatory_process.rb
decidim-core-0.0.7 app/controllers/concerns/decidim/needs_participatory_process.rb
decidim-core-0.0.6 app/controllers/concerns/decidim/needs_participatory_process.rb
decidim-core-0.0.5 app/controllers/concerns/decidim/needs_participatory_process.rb
decidim-core-0.0.3 app/controllers/concerns/decidim/needs_participatory_process.rb
decidim-core-0.0.2 app/controllers/concerns/decidim/needs_participatory_process.rb