Sha256: 8f5703ebc27cb62c2ccd24e0edd4c1bbd91cf4d41ee773d5bf6b7541ca9cc316
Contents?: true
Size: 1.6 KB
Versions: 9
Compression:
Stored size: 1.6 KB
Contents
# frozen_string_literal: true module Decidim module ParticipatoryProcesses # This module, when injected into a controller, ensures there's a # Participatory Process available and deducts it from the context. module NeedsParticipatoryProcess def self.enhance_controller(instance_or_module) instance_or_module.class_eval do helper_method :current_participatory_process end end def self.extended(base) base.extend Decidim::NeedsOrganization, InstanceMethods enhance_controller(base) end def self.included(base) base.include Decidim::NeedsOrganization, InstanceMethods enhance_controller(base) end module InstanceMethods # Public: Finds the current Participatory Process given this controller's # context. # # Returns the current ParticipatoryProcess. def current_participatory_process @current_participatory_process ||= detect_participatory_process end alias current_participatory_space current_participatory_process private def ability_context super.merge(current_participatory_process: current_participatory_process) end def detect_participatory_process request.env["current_participatory_process"] || organization_processes.find_by!(slug: params[:participatory_process_slug] || params[:slug]) end def organization_processes @organization_processes ||= OrganizationParticipatoryProcesses.new(current_organization).query end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems