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