Sha256: a874fdc91babf82c0d59bb3222e1d04ad53905134198cb582a0127e0ae32c29b
Contents?: true
Size: 1.32 KB
Versions: 15
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true module Decidim module Conferences # This class infers the current conference we are scoped to by # looking at the request parameters and the organization in the request # environment, and injects it into the environment. class CurrentConference # Public: Matches the request against a conference and injects it # into the environment. # # request - The request that holds the conference relevant # information. # # Returns a true if the request matched, false otherwise def matches?(request) env = request.env @organization = env["decidim.current_organization"] return false unless @organization current_conference(env, request.params) ? true : false end private def current_conference(env, params) env["decidim.current_participatory_space"] ||= detect_current_conference(params) end def detect_current_conference(params) organization_conferences.where(slug: params["conference_slug"]).or( organization_conferences.where(id: params["conference_slug"]) ).first! end def organization_conferences @organization_conferences ||= OrganizationConferences.new(@organization).query end end end end
Version data entries
15 entries across 15 versions & 1 rubygems