Sha256: 04730d54655d31f9cfe017d320c7caffd0973b0181325744775ed77fe32c2f0b

Contents?: true

Size: 1.01 KB

Versions: 33

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Decidim
  module Elections
    module Admin
      # This command gets called when a election is unpublished from the admin panel.
      class UnpublishElection < Rectify::Command
        # Public: Initializes the command.
        #
        # election - The election to unpublish.
        # current_user - the user performing the action
        def initialize(election, current_user)
          @election = election
          @current_user = current_user
        end

        # Public: Unpublishes the Election.
        #
        # Broadcasts :ok if unpublished, :invalid otherwise.
        def call
          unpublish_election

          broadcast(:ok)
        end

        private

        attr_reader :election, :current_user

        def unpublish_election
          Decidim.traceability.perform_action!(
            :unpublish,
            election,
            current_user
          ) do
            election.unpublish!
            election
          end
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

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