Sha256: 078a1d509ddee2ebd00e7f55058dcd35d632c0e8bcb9ddc4ff2c5e41998eab7c

Contents?: true

Size: 1.22 KB

Versions: 32

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

module Decidim
  module Debates
    module Admin
      # This command is executed when the user changes a Debate from the admin
      # panel.
      class UpdateDebate < Rectify::Command
        # Initializes a UpdateDebate Command.
        #
        # form - The form from which to get the data.
        # debate - The current instance of the page to be updated.
        def initialize(form, debate)
          @form = form
          @debate = debate
        end

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

          update_debate
          broadcast(:ok)
        end

        private

        attr_reader :debate, :form

        def update_debate
          Decidim.traceability.update!(
            debate,
            form.current_user,
            category: form.category,
            title: form.title,
            description: form.description,
            information_updates: form.information_updates,
            instructions: form.instructions,
            end_time: form.end_time,
            start_time: form.start_time
          )
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
decidim-debates-0.22.0 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.21.0 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.20.1 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.20.0 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.19.1 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.18.1 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.19.0 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.17.2 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.18.0 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.17.1 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.16.1 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.17.0 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.16.0 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.15.2 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.15.1 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.15.0 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.14.4 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.14.3 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.14.2 app/commands/decidim/debates/admin/update_debate.rb
decidim-debates-0.14.1 app/commands/decidim/debates/admin/update_debate.rb