Class: Decidim::Votings::VotingsController
Overview
A controller that holds the logic to show votings in a public layout.
Constant Summary
Constants included
from Paginable
Paginable::OPTIONS
Instance Method Summary
collapse
#ballot_questions, #can_preview?, #default_vote_flow, #preview_mode?, #vote_flow
enhance_controller, included
register_permissions
#check_user_block_status, #check_user_not_blocked
#snippets
#disable_http_caching
#skip_store_location?, #store_current_location
enhance_controller, extended, included
Instance Method Details
#check_census ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'decidim-elections/app/controllers/decidim/votings/votings_controller.rb', line 56
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:
)
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:, not_found:, datum: }
end
|
#elections_log ⇒ Object
93
94
95
|
# File 'decidim-elections/app/controllers/decidim/votings/votings_controller.rb', line 93
def elections_log
redirect_to election_log_path(elections.first) if elections.length == 1
end
|
#index ⇒ Object
28
29
30
31
32
33
|
# File 'decidim-elections/app/controllers/decidim/votings/votings_controller.rb', line 28
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
43
44
45
46
47
|
# File 'decidim-elections/app/controllers/decidim/votings/votings_controller.rb', line 43
def login
@form = form(Census::LoginForm).from_params(params, election:)
render :login
end
|
#send_access_code ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
|
# File 'decidim-elections/app/controllers/decidim/votings/votings_controller.rb', line 81
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: }
end
|
#show ⇒ Object
35
36
37
38
39
|
# File 'decidim-elections/app/controllers/decidim/votings/votings_controller.rb', line 35
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
49
50
51
52
53
54
|
# File 'decidim-elections/app/controllers/decidim/votings/votings_controller.rb', line 49
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
|