Class: Decidim::Elections::CensusChecksController

Inherits:
ApplicationController show all
Includes:
UsesCensusAccess
Defined in:
app/controllers/decidim/elections/census_checks_controller.rb

Overview

Allows participants to verify they belong to an election census before voting starts.

Instance Method Summary collapse

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/decidim/elections/census_checks_controller.rb', line 21

def create
  enforce_permission_to(:create, :census_check, election:)

  @form = election.census.form_instance(params, election:, current_user:)
  if @form.valid?
    session[:session_attributes] = @form.attributes
    redirect_to election_census_check_path(election)
  else
    flash[:alert] = @form.errors.full_messages.join("<br>").presence || t("failed", scope: "decidim.elections.votes.check_census")
    redirect_to new_election_census_check_path(election)
  end
end

#newObject



14
15
16
17
18
19
# File 'app/controllers/decidim/elections/census_checks_controller.rb', line 14

def new
  enforce_permission_to(:create, :census_check, election:)

  @form = election.census.form_instance({}, election:, current_user:)
  render "decidim/elections/votes/new"
end

#showObject



34
35
36
# File 'app/controllers/decidim/elections/census_checks_controller.rb', line 34

def show
  enforce_permission_to(:read, :census_check, election:)
end