Sha256: 361d15c0ceaf6d00d45b13f6688c4f1c8a69bb5c95d6b14cd9abb1f9eb832f75

Contents?: true

Size: 1 KB

Versions: 25

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    module Admin
      # This command gets called when a voting is published from the admin panel.
      class PublishVoting < Rectify::Command
        # Public: Initializes the command.
        #
        # voting - The voting to publish.
        # current_user - the user performing the action
        def initialize(voting, current_user)
          @voting = voting
          @current_user = current_user
        end

        # Public: Publishes the Voting.
        #
        # Broadcasts :ok if published, :invalid otherwise.
        def call
          return broadcast(:invalid) if voting.nil? || voting.published?

          publish_voting

          broadcast(:ok, voting)
        end

        private

        attr_reader :voting, :current_user

        def publish_voting
          Decidim.traceability.perform_action!(:publish, voting, current_user, visibility: "all") do
            voting.publish!
          end
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

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