Class: Decidim::Votings::PollingOfficerZone::InPersonVotesController

Inherits:
ApplicationController show all
Includes:
Elections::HasVoteFlow, FormFactory
Defined in:
decidim-elections/app/controllers/decidim/votings/polling_officer_zone/in_person_votes_controller.rb

Overview

Space to manage the elections for a Polling Station Officer

Instance Method Summary collapse

Methods included from Elections::HasVoteFlow

#ballot_questions, #can_preview?, #default_vote_flow, #preview_mode?, #vote_flow

Methods included from UserProfile

#available_verification_workflows

Methods included from UserGroups

#enforce_user_groups_enabled

Methods included from UserBlockedChecker

#check_user_block_status, #check_user_not_blocked

Methods included from NeedsSnippets

#snippets

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from HasStoredPath

#skip_store_location?, #store_current_location

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#createObject


23
24
25
26
27
28
29
30
31
32
33
# File 'decidim-elections/app/controllers/decidim/votings/polling_officer_zone/in_person_votes_controller.rb', line 23

def create
  enforce_permission_to :manage, :in_person_vote, polling_officer: polling_officer

  return if has_pending_in_person_vote?

  if verified_voter?
    store_in_person_vote
  else
    identify_voter
  end
end

#newObject


17
18
19
20
21
# File 'decidim-elections/app/controllers/decidim/votings/polling_officer_zone/in_person_votes_controller.rb', line 17

def new
  enforce_permission_to :manage, :in_person_vote, polling_officer: polling_officer

  has_pending_in_person_vote?
end

#showObject


35
36
37
# File 'decidim-elections/app/controllers/decidim/votings/polling_officer_zone/in_person_votes_controller.rb', line 35

def show
  enforce_permission_to :manage, :in_person_vote, polling_officer: polling_officer
end

#updateObject


39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'decidim-elections/app/controllers/decidim/votings/polling_officer_zone/in_person_votes_controller.rb', line 39

def update
  enforce_permission_to :manage, :in_person_vote, polling_officer: polling_officer

  Decidim::Votings::Voter::UpdateInPersonVoteStatus.call(in_person_vote) do
    on(:ok) do
      message_type = in_person_vote.accepted? ? :notice : :alert
      flash[message_type] = I18n.t("in_person_votes.update.success.#{in_person_vote.status}", scope: "decidim.votings.polling_officer_zone")
    end
    on(:invalid) do
      flash[:alert] = I18n.t("in_person_votes.update.error", scope: "decidim.votings.polling_officer_zone")
    end
  end
  redirect_to exit_path
end