Sha256: adfd46a94730c3459b5a47a00d378d170008705c4e2e1fc12dd2b80ca264e784
Contents?: true
Size: 1.18 KB
Versions: 3
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true module Decidim module Elections module Admin # This command is executed when the user creates a Question # from the admin panel. class CreateQuestion < Rectify::Command def initialize(form) @form = form end # Creates the question if valid. # # Broadcasts :ok if successful, :invalid otherwise. def call return broadcast(:election_started) if form.election.blocked? return broadcast(:invalid) if form.invalid? create_question! broadcast(:ok, question) end private attr_reader :form, :question def create_question! attributes = { election: form.election, title: form.title, max_selections: form.max_selections, weight: form.weight, random_answers_order: form.random_answers_order, min_selections: form.min_selections } @question = Decidim.traceability.create!( Question, form.current_user, attributes, visibility: "all" ) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems