Sha256: a678d2a338d6c2a34c7917f2c4e7f0386aeae6485c14cc94c3ed5b9ee884c433

Contents?: true

Size: 1.47 KB

Versions: 19

Compression:

Stored size: 1.47 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?
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
decidim-elections-0.26.10 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.26.9 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.26.8 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.26.7 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.26.5 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.26.4 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.26.3 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.26.2 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.26.1 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.26.0 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.26.0.rc2 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.26.0.rc1 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.25.2 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.25.1 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.25.0 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.25.0.rc4 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.25.0.rc3 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.25.0.rc2 app/controllers/decidim/elections/trustee_zone/elections_controller.rb
decidim-elections-0.25.0.rc1 app/controllers/decidim/elections/trustee_zone/elections_controller.rb