Sha256: 05f202ef5f2ebe34c1555219f73f0655b8a1145938d6fa18e677f3d147b4d772

Contents?: true

Size: 919 Bytes

Versions: 19

Compression:

Stored size: 919 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 < Rectify::Command
        def initialize(form)
          @form = form
        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 = Status.create!(
            feature: @form.current_feature,
            key: @form.key,
            name: @form.name,
            description: @form.description,
            progress: @form.progress
          )
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
decidim-accountability-0.10.1 app/commands/decidim/accountability/admin/create_status.rb
decidim-accountability-0.10.0 app/commands/decidim/accountability/admin/create_status.rb
decidim-accountability-0.9.3 app/commands/decidim/accountability/admin/create_status.rb
decidim-accountability-0.9.2 app/commands/decidim/accountability/admin/create_status.rb
decidim-accountability-0.9.1 app/commands/decidim/accountability/admin/create_status.rb
decidim-accountability-0.9.0 app/commands/decidim/accountability/admin/create_status.rb
decidim-accountability-0.8.4 app/commands/decidim/accountability/admin/create_status.rb
decidim-accountability-0.8.3 app/commands/decidim/accountability/admin/create_status.rb
decidim-accountability-0.8.2 app/commands/decidim/accountability/admin/create_status.rb
decidim-accountability-0.8.1 app/commands/decidim/accountability/admin/create_status.rb
decidim-accountability-0.8.0 app/commands/decidim/accountability/admin/create_status.rb
decidim-accountability-0.7.4 app/commands/decidim/accountability/admin/create_status.rb
decidim-accountability-0.7.3 app/commands/decidim/accountability/admin/create_status.rb
decidim-accountability-0.7.2 app/commands/decidim/accountability/admin/create_status.rb
decidim-accountability-0.7.1 app/commands/decidim/accountability/admin/create_status.rb
decidim-accountability-0.7.0 app/commands/decidim/accountability/admin/create_status.rb
decidim-accountability-0.1.2 app/commands/decidim/accountability/admin/create_status.rb
decidim-accountability-0.1.1 app/commands/decidim/accountability/admin/create_status.rb
decidim-accountability-0.1.0 app/commands/decidim/accountability/admin/create_status.rb