Sha256: 0bfdbf81bf4440e1782361167cb3bf63b25320455bfe25b3dea6054ce9860c2b

Contents?: true

Size: 902 Bytes

Versions: 33

Compression:

Stored size: 902 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Templates
    module Admin
      # Creates a QuestionnaireTemplate.
      class CreateQuestionnaireTemplate < Rectify::Command
        # Initializes the command.
        #
        # form - The source for this QuestionnaireTemplate.
        def initialize(form)
          @form = form
        end

        def call
          return broadcast(:invalid) unless @form.valid?

          @template = Decidim.traceability.create!(
            Template,
            @form.current_user,
            name: @form.name,
            description: @form.description,
            organization: @form.current_organization
          )

          @questionnaire = Decidim::Forms::Questionnaire.create!(questionnaire_for: @template)
          @template.update!(templatable: @questionnaire)

          broadcast(:ok, @template)
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
decidim-templates-0.26.10 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.26.9 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.26.8 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.26.7 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.26.5 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.26.4 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.26.3 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.26.2 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.26.1 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.26.0 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.26.0.rc2 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.26.0.rc1 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.25.2 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.25.1 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.25.0 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.25.0.rc4 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.25.0.rc3 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.25.0.rc2 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.25.0.rc1 app/commands/decidim/templates/admin/create_questionnaire_template.rb
decidim-templates-0.24.3 app/commands/decidim/templates/admin/create_questionnaire_template.rb