Sha256: 404864e3c2a582b0545ac806a1297fbaa8b024ba8c062b90b2de7a4864b4b8a9

Contents?: true

Size: 981 Bytes

Versions: 82

Compression:

Stored size: 981 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Accountability
    module Admin
      # This command is executed when the user creates a TimelineEntry
      # for a Result from the admin panel.
      class CreateTimelineEntry < Rectify::Command
        def initialize(form)
          @form = form
        end

        # Creates the timeline_entry if valid.
        #
        # Broadcasts :ok if successful, :invalid otherwise.
        def call
          return broadcast(:invalid) if @form.invalid?

          transaction do
            create_timeline_entry
          end

          broadcast(:ok)
        end

        private

        attr_reader :timeline_entry

        def create_timeline_entry
          @timeline_entry = TimelineEntry.create!(
            decidim_accountability_result_id: @form.decidim_accountability_result_id,
            entry_date: @form.entry_date,
            description: @form.description
          )
        end
      end
    end
  end
end

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
decidim-accountability-0.12.0.pre app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.11.1 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.11.0.pre1 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.10.1 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.10.0 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.9.3 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.9.2 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.9.1 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.9.0 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.8.4 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.8.3 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.8.2 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.8.1 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.8.0 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.7.4 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.7.3 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.7.2 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.7.1 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.7.0 app/commands/decidim/accountability/admin/create_timeline_entry.rb
decidim-accountability-0.1.2 app/commands/decidim/accountability/admin/create_timeline_entry.rb