Class: Decidim::Votings::Admin::MonitoringCommitteePollingStationClosuresController

Inherits:
ApplicationController show all
Includes:
MonitoringCommitteePollingStationClosures::Admin::Filterable, VotingAdmin
Defined in:
decidim-elections/app/controllers/decidim/votings/admin/monitoring_committee_polling_station_closures_controller.rb

Overview

This controller allows a monitoring committee member to list and validate the polling stations closures.

Instance Method Summary collapse

Methods inherited from Admin::ApplicationController

#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from NeedsSnippets

#snippets

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#editObject


23
24
25
26
27
# File 'decidim-elections/app/controllers/decidim/votings/admin/monitoring_committee_polling_station_closures_controller.rb', line 23

def edit
  enforce_permission_to :validate, :monitoring_committee_polling_station_closure, voting: current_voting, closure: closure

  @form = form(MonitoringCommitteePollingStationClosureForm).from_model(closure)
end

#indexObject


13
14
15
16
17
# File 'decidim-elections/app/controllers/decidim/votings/admin/monitoring_committee_polling_station_closures_controller.rb', line 13

def index
  enforce_permission_to :read, :monitoring_committee_polling_station_closures, voting: current_voting

  redirect_to voting_monitoring_committee_polling_station_closures_path(current_voting, election_id: elections.first.id) if elections.one? && params[:election_id].blank?
end

#showObject


19
20
21
# File 'decidim-elections/app/controllers/decidim/votings/admin/monitoring_committee_polling_station_closures_controller.rb', line 19

def show
  enforce_permission_to :read, :monitoring_committee_polling_station_closure, voting: current_voting, closure: closure
end

#validateObject


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'decidim-elections/app/controllers/decidim/votings/admin/monitoring_committee_polling_station_closures_controller.rb', line 29

def validate
  enforce_permission_to :validate, :monitoring_committee_polling_station_closure, voting: current_voting, closure: closure

  @form = form(MonitoringCommitteePollingStationClosureForm).from_params(params)

  MonitoringCommitteeValidatePollingStationClosure.call(@form, closure) do
    on(:ok) do
      flash[:notice] = t(".success")
    end

    on(:invalid) do
      flash[:alert] = t(".error")
    end
  end

  redirect_to voting_monitoring_committee_polling_station_closures_path(current_voting, election_id: closure.election.id)
end