Sha256: db9937f442a461239ef86f3ec83e1070ff62ac40fc93a43c5b0f4dd95dbf0b6e

Contents?: true

Size: 1.02 KB

Versions: 19

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    # The data store for a Questionnaire in the Decidim::Meetings component.
    class Questionnaire < Meetings::ApplicationRecord
      include Decidim::Traceable

      belongs_to :questionnaire_for, polymorphic: true

      has_many :questions, -> { order(:position) }, class_name: "Question", foreign_key: "decidim_questionnaire_id", dependent: :destroy
      has_many :answers, class_name: "Answer", foreign_key: "decidim_questionnaire_id", dependent: :destroy

      # Public: returns whether the questionnaire questions can be modified or not.
      def questions_editable?
        has_component = questionnaire_for.meeting.respond_to? :component
        (has_component && !questionnaire_for.meeting.component.published?) || answers.empty?
      end

      def all_questions_unpublished?
        questions.all?(&:unpublished?)
      end

      def self.log_presenter_class_for(_log)
        Decidim::Meetings::AdminLog::QuestionnairePresenter
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
decidim-meetings-0.28.4 app/models/decidim/meetings/questionnaire.rb
decidim-meetings-0.27.9 app/models/decidim/meetings/questionnaire.rb
decidim-meetings-0.28.3 app/models/decidim/meetings/questionnaire.rb
decidim-meetings-0.27.8 app/models/decidim/meetings/questionnaire.rb
decidim-meetings-0.28.2 app/models/decidim/meetings/questionnaire.rb
decidim-meetings-0.27.7 app/models/decidim/meetings/questionnaire.rb
decidim-meetings-0.28.1 app/models/decidim/meetings/questionnaire.rb
decidim-meetings-0.27.6 app/models/decidim/meetings/questionnaire.rb
decidim-meetings-0.28.0 app/models/decidim/meetings/questionnaire.rb
decidim-meetings-0.27.5 app/models/decidim/meetings/questionnaire.rb
decidim-meetings-0.28.0.rc5 app/models/decidim/meetings/questionnaire.rb
decidim-meetings-0.28.0.rc4 app/models/decidim/meetings/questionnaire.rb
decidim-meetings-0.27.4 app/models/decidim/meetings/questionnaire.rb
decidim-meetings-0.27.3 app/models/decidim/meetings/questionnaire.rb
decidim-meetings-0.27.2 app/models/decidim/meetings/questionnaire.rb
decidim-meetings-0.27.1 app/models/decidim/meetings/questionnaire.rb
decidim-meetings-0.27.0 app/models/decidim/meetings/questionnaire.rb
decidim-meetings-0.27.0.rc2 app/models/decidim/meetings/questionnaire.rb
decidim-meetings-0.27.0.rc1 app/models/decidim/meetings/questionnaire.rb