Class: Decidim::Sortitions::Admin::SortitionsController
- Inherits:
-
ApplicationController
- Object
- Admin::Features::BaseController
- ApplicationController
- Decidim::Sortitions::Admin::SortitionsController
- Defined in:
- app/controllers/decidim/sortitions/admin/sortitions_controller.rb
Overview
Controller responsible of the sortition that selects proposals from a participatory space.
Instance Method Summary collapse
- #confirm_destroy ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#confirm_destroy ⇒ Object
59 60 61 62 |
# File 'app/controllers/decidim/sortitions/admin/sortitions_controller.rb', line 59 def confirm_destroy :destroy, sortition @form = destroy_sortition_form.from_model(sortition, current_participatory_space: current_participatory_space) end |
#create ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/decidim/sortitions/admin/sortitions_controller.rb', line 43 def create :create, Sortition @form = sortition_form.from_params(params, current_participatory_space: current_participatory_space) CreateSortition.call(@form) do on(:ok) do |sortition| flash[:notice] = I18n.t("sortitions.create.success", scope: "decidim.sortitions.admin") redirect_to action: :show, id: sortition.id end on(:invalid) do flash.now[:alert] = I18n.t("sortitions.create.error", scope: "decidim.sortitions.admin") render :new end end end |
#destroy ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/controllers/decidim/sortitions/admin/sortitions_controller.rb', line 64 def destroy :destroy, sortition @form = destroy_sortition_form.from_params(params, current_participatory_space: current_participatory_space) DestroySortition.call(@form) do on(:ok) do |_sortition| flash[:notice] = I18n.t("sortitions.destroy.success", scope: "decidim.sortitions.admin") redirect_to action: :index end on(:invalid) do flash.now[:alert] = I18n.t("sortitions.destroy.error", scope: "decidim.sortitions.admin") render :confirm_destroy end end end |
#edit ⇒ Object
17 18 19 20 |
# File 'app/controllers/decidim/sortitions/admin/sortitions_controller.rb', line 17 def edit :update, sortition @form = edit_sortition_form.from_model(sortition, current_participatory_space: current_participatory_space) end |
#index ⇒ Object
11 |
# File 'app/controllers/decidim/sortitions/admin/sortitions_controller.rb', line 11 def index; end |
#new ⇒ Object
38 39 40 41 |
# File 'app/controllers/decidim/sortitions/admin/sortitions_controller.rb', line 38 def new :create, Sortition @form = sortition_form.instance(current_participatory_space: current_participatory_space) end |
#show ⇒ Object
13 14 15 |
# File 'app/controllers/decidim/sortitions/admin/sortitions_controller.rb', line 13 def show :show, sortition end |
#update ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/decidim/sortitions/admin/sortitions_controller.rb', line 22 def update :update, sortition @form = edit_sortition_form.from_params(params, current_participatory_space: current_participatory_space) UpdateSortition.call(@form) do on(:ok) do |_sortition| flash[:notice] = I18n.t("sortitions.update.success", scope: "decidim.sortitions.admin") redirect_to action: :index end on(:invalid) do flash.now[:alert] = I18n.t("sortitions.update.error", scope: "decidim.sortitions.admin") render :edit end end end |