Sha256: fb91ce6bd3cb85853db5e4c82ce54e6f31f4c260c7eb843d47625fb3127dd13c

Contents?: true

Size: 780 Bytes

Versions: 7

Compression:

Stored size: 780 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?, 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

7 entries across 7 versions & 1 rubygems

Version Path
decidim-surveys-0.19.1 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.18.1 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.19.0 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.17.2 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.18.0 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.17.1 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.17.0 app/controllers/decidim/surveys/surveys_controller.rb