Class: Decidim::Budgets::Admin::BudgetsController
- Inherits:
-
ApplicationController
- Object
- DecidimController
- Admin::ApplicationController
- Admin::Components::BaseController
- ApplicationController
- Decidim::Budgets::Admin::BudgetsController
- Includes:
- Admin::HasTrashableResources
- Defined in:
- decidim-budgets/app/controllers/decidim/budgets/admin/budgets_controller.rb
Overview
This controller allows the create or update a budget.
Instance Method Summary collapse
Methods inherited from ApplicationController
#maps_enabled?, #project, #projects
Methods inherited from Admin::Components::BaseController
#current_component, #current_participatory_space, #parent_path, #permission_class_chain, #permission_scope, #permissions_context, #set_component_breadcrumb_item, #skip_manage_component_permission
Methods included from RegistersPermissions
Methods inherited from Admin::ApplicationController
#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path
Methods included from Headers::HttpCachingDisabler
Methods included from TranslatableAttributes
#attachment?, #default_locale?
Methods included from NeedsSnippets
Methods included from NeedsOrganization
enhance_controller, extended, included
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'decidim-budgets/app/controllers/decidim/budgets/admin/budgets_controller.rb', line 17 def create :create, :budget @form = form(BudgetForm).from_params(params, current_component:) CreateBudget.call(@form) do on(:ok) do flash[:notice] = I18n.t("budgets.create.success", scope: "decidim.budgets.admin") redirect_to budgets_path end on(:invalid) do flash.now[:alert] = I18n.t("budgets.create.invalid", scope: "decidim.budgets.admin") render action: "new" end end end |
#edit ⇒ Object
34 35 36 37 |
# File 'decidim-budgets/app/controllers/decidim/budgets/admin/budgets_controller.rb', line 34 def edit (:update, :budget, budget:) @form = form(BudgetForm).from_model(budget) end |
#new ⇒ Object
12 13 14 15 |
# File 'decidim-budgets/app/controllers/decidim/budgets/admin/budgets_controller.rb', line 12 def new :create, :budget @form = form(BudgetForm).instance end |
#update ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'decidim-budgets/app/controllers/decidim/budgets/admin/budgets_controller.rb', line 39 def update (:update, :budget, budget:) @form = form(BudgetForm).from_params(params, current_component:) UpdateBudget.call(@form, budget) do on(:ok) do flash[:notice] = I18n.t("budgets.update.success", scope: "decidim.budgets.admin") redirect_to budgets_path end on(:invalid) do flash.now[:alert] = I18n.t("budgets.update.invalid", scope: "decidim.budgets.admin") render action: "edit" end end end |