Sha256: 82d17ffb4800958d09b52097c5079e08234a259ac5e2b1ddcaf39fa585447aa5

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Decidim
  module Debates
    # A command with all the business logic when a user updates a debate.
    class UpdateDebate < Decidim::Commands::UpdateResource
      fetch_form_attributes :category, :scope

      private

      def update_resource
        with_events(with_transaction: true) do
          super
        end
      end

      def event_arguments
        {
          resource:,
          extra: {
            event_author: form.current_user,
            locale:
          }
        }
      end

      def extra_params = { visibility: "public-only" }

      def attributes
        parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
        parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.description, current_organization: form.current_organization).rewrite

        super.merge({
                      title: { I18n.locale => parsed_title },
                      description: { I18n.locale => parsed_description }
                    })
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-debates-0.29.1 app/commands/decidim/debates/update_debate.rb
decidim-debates-0.29.0 app/commands/decidim/debates/update_debate.rb
decidim-debates-0.29.0.rc4 app/commands/decidim/debates/update_debate.rb
decidim-debates-0.29.0.rc3 app/commands/decidim/debates/update_debate.rb
decidim-debates-0.29.0.rc2 app/commands/decidim/debates/update_debate.rb
decidim-debates-0.29.0.rc1 app/commands/decidim/debates/update_debate.rb