Sha256: c2dbcf537abe159a59b3dcb4cea0ec1caf77cac405b97dc957b70dcc1674697d
Contents?: true
Size: 1.16 KB
Versions: 13
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module Decidim module Templates module Admin # Updates the questionnaire template given form data. class UpdateTemplate < Decidim::Command # Initializes the command. # # template - The Template to update. # form - The form object containing the data to update. # user - The user that updates the template. def initialize(template, form, user) @template = template @form = form @user = user end # Executes the command. Broadcasts these events: # # - :ok when everything is valid. # - :invalid if the form was not valid and we could not proceed. # # Returns nothing. def call return broadcast(:invalid) unless @form.valid? return broadcast(:invalid) unless @user.organization == @template.organization @template = Decidim.traceability.update!( @template, @user, name: @form.name, description: @form.description ) broadcast(:ok, @template) end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems