Sha256: 0b01d91b2702e00e4f4978b2bd56b265ef4c2024307db454eed088639f6dc050

Contents?: true

Size: 1.48 KB

Versions: 12

Compression:

Stored size: 1.48 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: trustee
        end

        def update
          enforce_permission_to :update, :election, trustee: 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

12 entries across 12 versions & 1 rubygems

Version Path
decidim-elections-0.27.9 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.27.8 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.27.7 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.27.6 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.27.5 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.27.4 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.27.3 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.27.2 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.27.1 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.27.0 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.27.0.rc2 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.27.0.rc1 app/controllers/decidim/elections/trustee_zone/elections_controller.rb