Sha256: d430edc13286a073d4aeaeeb09845b3feb89d6c3f6fe4002d758d1f71a0c2d33
Contents?: true
Size: 1005 Bytes
Versions: 20
Compression:
Stored size: 1005 Bytes
Contents
# frozen_string_literal: true module Decidim module Accountability module Admin # This command is executed when the user creates a Status from the admin # panel. class CreateStatus < Decidim::Command def initialize(form, user) @form = form @user = user end # Creates the status if valid. # # Broadcasts :ok if successful, :invalid otherwise. def call return broadcast(:invalid) if @form.invalid? transaction do create_status end broadcast(:ok) end private attr_reader :status def create_status @status = Decidim.traceability.create!( Status, @user, component: @form.current_component, key: @form.key, name: @form.name, description: @form.description, progress: @form.progress ) end end end end end
Version data entries
20 entries across 20 versions & 1 rubygems