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
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/decidim/votings/admin/polling_stations_controller.rb', line 23 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
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/controllers/decidim/votings/admin/polling_stations_controller.rb', line 62 def destroy :delete, :polling_station, voting: current_voting, polling_station: 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
40 41 42 43 |
# File 'app/controllers/decidim/votings/admin/polling_stations_controller.rb', line 40 def edit :update, :polling_station, voting: current_voting, polling_station: polling_station @form = form(PollingStationForm).from_model(polling_station, voting: current_voting) end |
#index ⇒ Object
14 15 16 |
# File 'app/controllers/decidim/votings/admin/polling_stations_controller.rb', line 14 def index :read, :polling_stations, voting: current_voting end |
#new ⇒ Object
18 19 20 21 |
# File 'app/controllers/decidim/votings/admin/polling_stations_controller.rb', line 18 def new :create, :polling_station, voting: current_voting @form = form(PollingStationForm).instance end |
#update ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/decidim/votings/admin/polling_stations_controller.rb', line 45 def update :update, :polling_station, voting: current_voting, polling_station: 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 |