Sha256: 3b91a2f79ca4506b6aaf36fc681bf6b896bdbbf6fadc39f8958be80f556d9479
Contents?: true
Size: 1.25 KB
Versions: 20
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true module Decidim module Elections module Admin # This command updates the status of the action and the election if it got changed class UpdateActionStatus < Decidim::Command # Public: Initializes the command. # # action - The pending action to be updated def initialize(action) @action = action end # Update the statuses of the action and the election if pending message status got changed. # # Broadcasts :ok if successful, :invalid otherwise. def call return broadcast(:ok) unless action.pending? transaction do update_pending_message_status update_election_status if action.accepted? end broadcast(:ok) end private attr_reader :action delegate :election, to: :action def update_pending_message_status action.status = Decidim::Elections.bulletin_board.get_pending_message_status(action.message_id) action.save! end def update_election_status election.bb_status = Decidim::Elections.bulletin_board.get_election_status(election.id) election.save! end end end end end
Version data entries
20 entries across 20 versions & 1 rubygems