Sha256: 7874fc3c26844a314d74f2324b8e33ac82fb5fafd8f11126fcd84f5108b7b3c0

Contents?: true

Size: 1.15 KB

Versions: 19

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    module Admin
      # A command with all the business logic that unpublishes an
      # existing meeting.
      class UnpublishMeeting < Rectify::Command
        # Public: Initializes the command.
        #
        # meeting - Decidim::Meetings::Meeting
        # current_user - the user performing the action
        def initialize(meeting, current_user)
          @meeting = meeting
          @current_user = current_user
        end

        # Executes the command. Broadcasts these events:
        #
        # - :ok when everything is valid.
        # - :invalid if the form wasn't valid and we couldn't proceed.
        #
        # Returns nothing.
        def call
          return broadcast(:invalid) unless meeting.published?

          @meeting = Decidim.traceability.perform_action!(
            :unpublish,
            meeting,
            current_user,
            visibility: "all"
          ) do
            meeting.unpublish!
            meeting
          end
          broadcast(:ok, meeting)
        end

        private

        attr_reader :meeting, :current_user
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
decidim-meetings-0.26.10 app/commands/decidim/meetings/admin/unpublish_meeting.rb
decidim-meetings-0.26.9 app/commands/decidim/meetings/admin/unpublish_meeting.rb
decidim-meetings-0.26.8 app/commands/decidim/meetings/admin/unpublish_meeting.rb
decidim-meetings-0.26.7 app/commands/decidim/meetings/admin/unpublish_meeting.rb
decidim-meetings-0.26.5 app/commands/decidim/meetings/admin/unpublish_meeting.rb
decidim-meetings-0.26.4 app/commands/decidim/meetings/admin/unpublish_meeting.rb
decidim-meetings-0.26.3 app/commands/decidim/meetings/admin/unpublish_meeting.rb
decidim-meetings-0.26.2 app/commands/decidim/meetings/admin/unpublish_meeting.rb
decidim-meetings-0.26.1 app/commands/decidim/meetings/admin/unpublish_meeting.rb
decidim-meetings-0.26.0 app/commands/decidim/meetings/admin/unpublish_meeting.rb
decidim-meetings-0.26.0.rc2 app/commands/decidim/meetings/admin/unpublish_meeting.rb
decidim-meetings-0.26.0.rc1 app/commands/decidim/meetings/admin/unpublish_meeting.rb
decidim-meetings-0.25.2 app/commands/decidim/meetings/admin/unpublish_meeting.rb
decidim-meetings-0.25.1 app/commands/decidim/meetings/admin/unpublish_meeting.rb
decidim-meetings-0.25.0 app/commands/decidim/meetings/admin/unpublish_meeting.rb
decidim-meetings-0.25.0.rc4 app/commands/decidim/meetings/admin/unpublish_meeting.rb
decidim-meetings-0.25.0.rc3 app/commands/decidim/meetings/admin/unpublish_meeting.rb
decidim-meetings-0.25.0.rc2 app/commands/decidim/meetings/admin/unpublish_meeting.rb
decidim-meetings-0.25.0.rc1 app/commands/decidim/meetings/admin/unpublish_meeting.rb