Class: Decidim::Votings::Admin::PollingStationsController
- Inherits:
-
ApplicationController
- Object
- Admin::ApplicationController
- ApplicationController
- Decidim::Votings::Admin::PollingStationsController
- Includes:
- PollingStations::Admin::Filterable, VotingAdmin
- Defined in:
- app/controllers/decidim/votings/admin/polling_stations_controller.rb
Overview
This controller allows to create or update a polling station.
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/decidim/votings/admin/polling_stations_controller.rb', line 22 def create :create, :polling_station, voting: current_voting @form = form(PollingStationForm).from_params(params, voting: current_voting) CreatePollingStation.call(@form) do on(:ok) do flash[:notice] = I18n.t("polling_stations.create.success", scope: "decidim.votings.admin") redirect_to voting_polling_stations_path(current_voting) end on(:invalid) do flash.now[:alert] = I18n.t("polling_stations.create.invalid", scope: "decidim.votings.admin") render action: "new" end end end |
#destroy ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/controllers/decidim/votings/admin/polling_stations_controller.rb', line 61 def destroy (:delete, :polling_station, voting: current_voting, polling_station:) DestroyPollingStation.call(polling_station, current_user) do on(:ok) do flash[:notice] = I18n.t("polling_stations.destroy.success", scope: "decidim.votings.admin") end on(:invalid) do flash.now[:alert] = I18n.t("polling_stations.destroy.invalid", scope: "decidim.votings.admin") end end redirect_to voting_polling_stations_path(current_voting) end |
#edit ⇒ Object
39 40 41 42 |
# File 'app/controllers/decidim/votings/admin/polling_stations_controller.rb', line 39 def edit (:update, :polling_station, voting: current_voting, polling_station:) @form = form(PollingStationForm).from_model(polling_station, voting: current_voting) end |
#index ⇒ Object
13 14 15 |
# File 'app/controllers/decidim/votings/admin/polling_stations_controller.rb', line 13 def index :read, :polling_stations, voting: current_voting end |
#new ⇒ Object
17 18 19 20 |
# File 'app/controllers/decidim/votings/admin/polling_stations_controller.rb', line 17 def new :create, :polling_station, voting: current_voting @form = form(PollingStationForm).instance end |
#update ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/decidim/votings/admin/polling_stations_controller.rb', line 44 def update (:update, :polling_station, voting: current_voting, polling_station:) @form = form(PollingStationForm).from_params(params, voting: current_voting) UpdatePollingStation.call(@form, polling_station) do on(:ok) do flash[:notice] = I18n.t("polling_stations.update.success", scope: "decidim.votings.admin") redirect_to voting_polling_stations_path(current_voting) end on(:invalid) do flash.now[:alert] = I18n.t("polling_stations.update.invalid", scope: "decidim.votings.admin") render action: "edit" end end end |