Class: Decidim::Votings::VotingsController
Overview
A controller that holds the logic to show votings in a public layout.
Instance Method Summary
collapse
#ballot_questions, #can_preview?, #default_vote_flow, #preview_mode?, #vote_flow
enhance_controller, included
Instance Method Details
#check_census ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'app/controllers/decidim/votings/votings_controller.rb', line 58
def check_census
raise ActionController::RoutingError, "Not Found" unless current_participatory_space.check_census_enabled?
@form = form(Census::CheckForm).from_params(params).with_context(
current_participatory_space: current_participatory_space
)
success = not_found = false
datum = nil
CheckCensus.call(@form) do
on(:ok) do |census|
success = true
datum = census
end
on(:not_found) do
not_found = true
end
on(:invalid) do
flash[:alert] = t("check_census.invalid", scope: "decidim.votings.votings")
end
end
render action: :check_census, locals: { success: success, not_found: not_found, datum: datum }
end
|
#elections_log ⇒ Object
95
96
97
|
# File 'app/controllers/decidim/votings/votings_controller.rb', line 95
def elections_log
redirect_to election_log_path(elections.first) if elections.length == 1
end
|
#index ⇒ Object
29
30
31
32
33
34
|
# File 'app/controllers/decidim/votings/votings_controller.rb', line 29
def index
raise ActionController::RoutingError, "Not Found" if published_votings.none?
enforce_permission_to :read, :votings
redirect_to voting_path(single) if single?
end
|
#login ⇒ Object
44
45
46
47
48
49
|
# File 'app/controllers/decidim/votings/votings_controller.rb', line 44
def login
@form = form(Census::LoginForm).from_params(params, election: election)
render :login,
layout: "decidim/election_votes"
end
|
#send_access_code ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
|
# File 'app/controllers/decidim/votings/votings_controller.rb', line 83
def send_access_code
SendAccessCode.call(datum, params[:medium]) do
on(:ok) do
flash[:notice] = t("send_access_code.success", scope: "decidim.votings.votings")
end
on(:invalid) do
flash[:alert] = t("send_access_code.invalid", scope: "decidim.votings.votings")
end
end
render action: :check_census, locals: { success: true, not_found: false, datum: datum }
end
|
#show ⇒ Object
36
37
38
39
40
|
# File 'app/controllers/decidim/votings/votings_controller.rb', line 36
def show
raise ActionController::RoutingError, "Not Found" unless current_participatory_space
enforce_permission_to :read, :voting, voting: current_participatory_space
end
|
#show_check_census ⇒ Object
51
52
53
54
55
56
|
# File 'app/controllers/decidim/votings/votings_controller.rb', line 51
def show_check_census
raise ActionController::RoutingError, "Not Found" unless current_participatory_space.check_census_enabled?
@form = form(Census::CheckForm).instance
render :check_census, locals: { success: false, not_found: false }
end
|