Class: Decidim::Votings::PollingOfficerZone::ClosuresController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Decidim::Votings::PollingOfficerZone::ClosuresController
- Defined in:
- app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb
Overview
Space to manage the election closure of a Polling Station
Instance Method Summary collapse
- #certify ⇒ Object
- #create ⇒ Object
- #edit ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #sign ⇒ Object
- #update ⇒ Object
Instance Method Details
#certify ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb', line 71 def certify (:manage, :polling_station_results, polling_officer:) @form = form(ClosureCertifyForm).from_params(params).with_context(closure:) CertifyPollingStationClosure.call(@form, closure) do on(:ok) do flash[:notice] = t(".success") end on(:invalid) do flash[:alert] = t(".error") end end redirect_to polling_officer_election_closure_path(polling_officer, election) end |
#create ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb', line 30 def create (:manage, :polling_station_results, polling_officer:) @form = form(EnvelopesResultForm).from_params(params).with_context(polling_officer:) CreatePollingStationClosure.call(@form) do on(:ok) do flash[:notice] = t(".success") redirect_to edit_polling_officer_election_closure_path(polling_officer, election) end on(:invalid) do flash[:alert] = t(".error") render :new end end end |
#edit ⇒ Object
48 49 50 51 52 |
# File 'app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb', line 48 def edit (:manage, :polling_station_results, polling_officer:) @form = form(ClosureResultForm).from_model(closure) end |
#new ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb', line 20 def new (:manage, :polling_station_results, polling_officer:) @form = EnvelopesResultForm.new( polling_station_id: polling_station.id, election_id: election.id, election_votes_count: polling_station_election_votes_count ) end |
#show ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb', line 10 def show (:manage, :polling_station_results, polling_officer:) @form = if closure.certificate_phase? form(ClosureCertifyForm).instance.with_context(closure:) elsif closure.signature_phase? form(ClosureSignForm).instance end end |
#sign ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb', line 89 def sign (:manage, :polling_station_results, polling_officer:) @form = form(ClosureSignForm).from_params(params) SignPollingStationClosure.call(@form, closure) do on(:ok) do flash[:notice] = t(".success") end on(:invalid) do flash[:alert] = t(".error") end end redirect_to polling_officer_election_closure_path(polling_officer, election) end |
#update ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/decidim/votings/polling_officer_zone/closures_controller.rb', line 54 def update (:manage, :polling_station_results, polling_officer:) @form = form(ClosureResultForm).from_params(params) CreatePollingStationResults.call(@form, closure) do on(:ok) do flash[:notice] = t(".success") end on(:invalid) do flash[:alert] = t(".error") end end redirect_to polling_officer_election_closure_path(polling_officer, election) end |