Class: Decidim::Votings::CensusVoteFlow
Overview
Service that encapsulates the vote flow used for Votings, using a census instead of users.
Instance Method Summary
collapse
#initialize, #valid_received_data?, #voter_from_token, #voter_id, #voter_id_token, #voter_token
Instance Method Details
#ballot_style_id ⇒ Object
55
56
57
|
# File 'app/services/decidim/votings/census_vote_flow.rb', line 55
def ballot_style_id
ballot_style&.slug
end
|
#has_voter? ⇒ Boolean
15
16
17
|
# File 'app/services/decidim/votings/census_vote_flow.rb', line 15
def has_voter?
datum.present?
end
|
#login_path(online_vote_path) ⇒ Object
63
64
65
|
# File 'app/services/decidim/votings/census_vote_flow.rb', line 63
def login_path(online_vote_path)
EngineRouter.main_proxy(election.component.participatory_space).voting_login_path(election_id: election.id, vote_path: online_vote_path) if online_vote_path
end
|
#questions_for(election) ⇒ Object
47
48
49
50
51
52
53
|
# File 'app/services/decidim/votings/census_vote_flow.rb', line 47
def questions_for(election)
if ballot_style.present?
ballot_style.questions.where(election:)
else
election.questions
end
end
|
#user ⇒ Object
25
26
27
|
# File 'app/services/decidim/votings/census_vote_flow.rb', line 25
def user
nil
end
|
#vote_check(online_vote_path: nil) ⇒ Object
39
40
41
42
43
44
45
|
# File 'app/services/decidim/votings/census_vote_flow.rb', line 39
def vote_check(online_vote_path: nil)
VoteCheckResult.new(
allowed: has_voter? && !voted_in_person?,
error_message: I18n.t("vote_flow.#{voted_in_person? ? "already_voted_in_person" : "datum_not_found"}", scope: "decidim.votings.census"),
exit_path: login_path(online_vote_path)
)
end
|
#voted_in_person? ⇒ Boolean
#voter_data ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'app/services/decidim/votings/census_vote_flow.rb', line 29
def voter_data
return nil unless datum
{
id: datum.id,
created: datum.created_at.to_i,
name: datum.full_name
}
end
|
#voter_in_person(params) ⇒ Object
11
12
13
|
# File 'app/services/decidim/votings/census_vote_flow.rb', line 11
def voter_in_person(params)
@in_person_params = params
end
|
#voter_login(params) ⇒ Object
7
8
9
|
# File 'app/services/decidim/votings/census_vote_flow.rb', line 7
def voter_login(params)
@login_params = params
end
|
#voter_name ⇒ Object
19
20
21
|
# File 'app/services/decidim/votings/census_vote_flow.rb', line 19
def voter_name
datum&.full_name
end
|