Class: Decidim::Votings::Admin::BallotStylesController
- Inherits:
-
ApplicationController
- Object
- Admin::ApplicationController
- ApplicationController
- Decidim::Votings::Admin::BallotStylesController
- Includes:
- VotingAdmin
- Defined in:
- app/controllers/decidim/votings/admin/ballot_styles_controller.rb
Overview
This controller allows to create or update the ballot styles.
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/decidim/votings/admin/ballot_styles_controller.rb', line 20 def create :create, :ballot_style, voting: current_voting @form = form(BallotStyleForm).from_params(params, voting: current_voting) CreateBallotStyle.call(@form) do on(:ok) do flash[:notice] = I18n.t("create.success", scope: "decidim.votings.admin.ballot_styles") redirect_to voting_ballot_styles_path(current_voting) end on(:invalid) do flash[:alert] = t("create.error", scope: "decidim.votings.admin.ballot_styles") render action: "new" end end end |
#destroy ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/controllers/decidim/votings/admin/ballot_styles_controller.rb', line 60 def destroy :delete, :ballot_style, ballot_style: current_ballot_style, voting: current_voting DestroyBallotStyle.call(current_ballot_style, current_user) do on(:ok) do flash[:notice] = t("destroy.success", scope: "decidim.votings.admin.ballot_styles") end on(:invalid) do flash[:alert] = t("destroy.invalid", scope: "decidim.votings.admin.ballot_styles") end end redirect_to voting_ballot_styles_path(current_voting) end |
#edit ⇒ Object
38 39 40 41 |
# File 'app/controllers/decidim/votings/admin/ballot_styles_controller.rb', line 38 def edit :update, :ballot_style, ballot_style: current_ballot_style, voting: current_voting @form = form(BallotStyleForm).from_model(current_ballot_style, voting: current_voting) end |
#index ⇒ Object
11 12 13 |
# File 'app/controllers/decidim/votings/admin/ballot_styles_controller.rb', line 11 def index :read, :ballot_styles, voting: current_voting end |
#new ⇒ Object
15 16 17 18 |
# File 'app/controllers/decidim/votings/admin/ballot_styles_controller.rb', line 15 def new :create, :ballot_style, voting: current_voting @form = form(BallotStyleForm).instance end |
#update ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/decidim/votings/admin/ballot_styles_controller.rb', line 43 def update :update, :ballot_style, ballot_style: current_ballot_style, voting: current_voting @form = form(BallotStyleForm).from_params(params, voting: current_voting, ballot_style_id: current_ballot_style.id) UpdateBallotStyle.call(@form, current_ballot_style) do on(:ok) do flash[:notice] = I18n.t("update.success", scope: "decidim.votings.admin.ballot_styles") redirect_to voting_ballot_styles_path(current_voting) end on(:invalid) do flash.now[:alert] = I18n.t("update.invalid", scope: "decidim.votings.admin.ballot_styles") render action: "edit" end end end |