Sha256: 0376528a90b079fe1c50144a9878197407ea61f87e90da104c1ec1e033aabeea

Contents?: true

Size: 1.03 KB

Versions: 37

Compression:

Stored size: 1.03 KB

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
      include Decidim::ComponentPathHelper
      helper Decidim::Surveys::SurveyHelper

      delegate :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

      protected

      def allow_answers?
        !current_component.published? || (current_settings.allow_answers? && survey.open?)
      end

      def form_path
        main_component_path(current_component)
      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

37 entries across 37 versions & 1 rubygems

Version Path
decidim-surveys-0.27.9 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.27.8 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.27.7 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.27.6 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.26.10 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.26.9 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.27.5 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.26.8 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.27.4 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.27.3 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.26.7 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.26.5 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.27.2 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.27.1 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.26.4 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.27.0 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.26.3 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.27.0.rc2 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.27.0.rc1 app/controllers/decidim/surveys/surveys_controller.rb
decidim-surveys-0.26.2 app/controllers/decidim/surveys/surveys_controller.rb