Sha256: 4535f3cbbda154aaabf6d710546f9ace0c8f9b35ec0b5f23bbf7bd65e98c4d20

Contents?: true

Size: 1.46 KB

Versions: 7

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

module Decidim
  module Elections
    module TrusteeZone
      # Handles the KeyCeremony for trustee users
      class ElectionsController < Decidim::Elections::TrusteeZone::ApplicationController
        helper_method :election, :bulletin_board_server, :authority_slug, :authority_public_key, :current_step, :scheme_name

        def show
          enforce_permission_to :view, :election, trustee:
        end

        def update
          enforce_permission_to(:update, :election, trustee:)

          UpdateElectionBulletinBoardStatus.call(election, params[:status]) do
            on(:ok) do
              render :update
            end
            on(:invalid) do
              flash[:alert] = I18n.t("elections.update.error", scope: "decidim.elections.trustee_zone")
            end
          end
        end

        private

        delegate :bulletin_board_server, :authority_slug, :scheme_name, to: :bulletin_board_client

        def election
          @election ||= Decidim::Elections::Election.find(params[:election_id])
        end

        def bulletin_board_client
          @bulletin_board_client ||= Decidim::Elections.bulletin_board
        end

        def authority_public_key
          @authority_public_key ||= bulletin_board_client.authority_public_key.to_json
        end

        def current_step
          @current_step ||= election.bb_status if election.bb_key_ceremony? || election.bb_tally_started?
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-elections-0.28.4 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.28.3 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.28.2 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.28.1 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.28.0 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.28.0.rc5 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.28.0.rc4 app/controllers/decidim/elections/trustee_zone/elections_controller.rb