Sha256: 131c7e8227054f59656470aa2e5484b179464eb6fac90a2a870a38740cec0d01
Contents?: true
Size: 1.53 KB
Versions: 25
Compression:
Stored size: 1.53 KB
Contents
# frozen_string_literal: true module Decidim module Elections module Admin # This command gets called to start the voting period in the Bulletin Board. class StartVote < Rectify::Command # Public: Initializes the command. # # form - A VotePeriodForm object with the information needed to start or end the vote period def initialize(form) @form = form end # Public: Starts the voting period for the Election. # # Broadcasts :ok if setup, :invalid otherwise. def call return broadcast(:invalid) if form.invalid? transaction do log_action start_vote end broadcast(:ok) rescue StandardError => e broadcast(:invalid, e.message) end private attr_accessor :form delegate :election, :bulletin_board, to: :form def log_action Decidim.traceability.perform_action!( :start_vote, election, form.current_user, visibility: "all" ) end def start_vote bulletin_board.start_vote(election.id) do |message_id| create_election_action(message_id) end end def create_election_action(message_id) Decidim::Elections::Action.create!( election: election, action: :start_vote, message_id: message_id, status: :pending ) end end end end end
Version data entries
25 entries across 25 versions & 1 rubygems