Sha256: dcd80272680000b75fca96eec2c202d9e0d5dddba1488c065adccd19d7169e4a

Contents?: true

Size: 1.63 KB

Versions: 21

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    module Admin
      # This command is executed when the user changes a Minutes from the admin
      # panel.
      class UpdateMinutes < Rectify::Command
        # Initializes a UpdateMinutes Command.
        #
        # form - The form from which to get the data.
        # current_meeting - The current instance of the meeting.
        # minutes - The current instance of the minutes to be updated.
        def initialize(form, current_meeting, minutes)
          @form = form
          @current_meeting = current_meeting
          @minutes = minutes
        end

        # Updates the minute if valid.
        #
        # Broadcasts :ok if successful, :invalid otherwise.
        def call
          return broadcast(:invalid) if form.invalid?
          transaction do
            update_minutes!
          end

          broadcast(:ok, minutes)
        end

        private

        attr_reader :form, :current_meeting, :minutes

        def update_minutes!
          log_info = {
            resource: {
              title: @current_meeting.title
            },
            participatory_space: {
              title: @current_meeting.participatory_space.title
            }
          }

          @minutes = Decidim.traceability.update!(
            minutes,
            form.current_user,
            {
              description: form.description,
              video_url: form.video_url,
              audio_url: form.audio_url,
              visible: form.visible,
              meeting: current_meeting
            },
            log_info
          )
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
decidim-meetings-0.18.1 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.17.2 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.18.0 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.17.1 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.16.1 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.17.0 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.16.0 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.15.2 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.15.1 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.15.0 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.14.4 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.14.3 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.14.2 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.14.1 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.13.1 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.12.2 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.13.0 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.12.1 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.13.0.pre1 app/commands/decidim/meetings/admin/update_minutes.rb
decidim-meetings-0.12.0 app/commands/decidim/meetings/admin/update_minutes.rb