Sha256: 08fe61138144b0147b4b481d2b823ff9fd02c62a4b62b6cfb5a300111e9f7e91
Contents?: true
Size: 1.18 KB
Versions: 13
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 < Decidim::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
13 entries across 13 versions & 1 rubygems