Class: Decidim::Sortitions::Admin::SortitionsController
- Inherits:
-
ApplicationController
- Object
- Admin::Components::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
64 65 66 67 68 |
# File 'app/controllers/decidim/sortitions/admin/sortitions_controller.rb', line 64 def confirm_destroy (:destroy, :sortition, sortition:) @form = destroy_sortition_form.from_model(sortition, current_participatory_space:) end |
#create ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/controllers/decidim/sortitions/admin/sortitions_controller.rb', line 47 def create :create, :sortition @form = sortition_form.from_params(params, 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
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/controllers/decidim/sortitions/admin/sortitions_controller.rb', line 70 def destroy (:destroy, :sortition, sortition:) @form = destroy_sortition_form.from_params(params, 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
18 19 20 21 22 |
# File 'app/controllers/decidim/sortitions/admin/sortitions_controller.rb', line 18 def edit (:update, :sortition, sortition:) @form = edit_sortition_form.from_model(sortition, current_participatory_space:) end |
#index ⇒ Object
12 |
# File 'app/controllers/decidim/sortitions/admin/sortitions_controller.rb', line 12 def index; end |
#new ⇒ Object
41 42 43 44 45 |
# File 'app/controllers/decidim/sortitions/admin/sortitions_controller.rb', line 41 def new :create, :sortition @form = sortition_form.instance(current_participatory_space:) end |
#show ⇒ Object
14 15 16 |
# File 'app/controllers/decidim/sortitions/admin/sortitions_controller.rb', line 14 def show :read, :sortition, sortition: end |
#update ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/decidim/sortitions/admin/sortitions_controller.rb', line 24 def update (:update, :sortition, sortition:) @form = edit_sortition_form.from_params(params, 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 |