Sha256: 0b8834b5abf52eab294863b2b557c0ff97df57b8f7b812de7d08999f7a3306ba
Contents?: true
Size: 1.57 KB
Versions: 8
Compression:
Stored size: 1.57 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 < Rectify::Command # Public: Initializes the command. # # form - A form object with the params. def initialize(form) @form = form end # Executes the command. Broadcasts these events: # # - :ok when everything is valid, together with the debate. # - :invalid if the form wasn't valid and we couldn't proceed. # # Returns nothing. def call return broadcast(:invalid) if form.invalid? return broadcast(:invalid) unless form.debate.editable_by?(form.current_user) update_debate broadcast(:ok, @debate) end private attr_reader :form def update_debate @debate = Decidim.traceability.update!( @form.debate, @form.current_user, attributes, visibility: "public-only" ) end 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 { category: form.category, title: { I18n.locale => parsed_title }, description: { I18n.locale => parsed_description } } end end end end
Version data entries
8 entries across 8 versions & 1 rubygems