Sha256: df47440686688d7f88f5ed629170965a328572de124f4114686e35d30e1c00e3

Contents?: true

Size: 802 Bytes

Versions: 3

Compression:

Stored size: 802 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Surveys
    # Exposes the survey resource so users can view and answer them.
    class SurveysController < Decidim::Surveys::ApplicationController
      include Decidim::Forms::Concerns::HasQuestionnaire
      helper Decidim::Surveys::SurveyHelper

      delegate :allow_answers?, :allow_unregistered?, to: :current_settings

      before_action :check_permissions

      def check_permissions
        render :no_permission unless action_authorized_to(:answer, resource: survey).ok?
      end

      def questionnaire_for
        survey
      end

      private

      def i18n_flashes_scope
        "decidim.surveys.surveys"
      end

      def survey
        @survey ||= Survey.find_by(component: current_component)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-surveys-0.21.0 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.20.1 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.20.0 app/controllers/decidim/surveys/surveys_controller.rb