Class: Decidim::Lausanne::Budgets::LineItemsController
- Inherits:
-
ApplicationController
- Object
- Components::BaseController
- ApplicationController
- Decidim::Lausanne::Budgets::LineItemsController
- Includes:
- NeedsCurrentOrder
- Defined in:
- app/controllers/decidim/lausanne/budgets/line_items_controller.rb
Overview
Exposes the line items resource so users can create and remove from orders.
Instance Method Summary collapse
Methods inherited from ApplicationController
#current_user_record, #current_workflow, #show_votes_count?, #voting_finished?, #voting_open?
Instance Method Details
#create ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/decidim/lausanne/budgets/line_items_controller.rb', line 12 def create :vote, :project, project: project, budget: budget, workflow: current_workflow respond_to do |format| AddLineItem.call(persisted_current_order, project, current_user) do on(:ok) do |order| self.current_order = order format.html { redirect_back(fallback_location: lausanne_budget_path(budget)) } format.js { render "update_budget" } end on(:invalid) do render nothing: true, status: :unprocessable_entity end end end end |
#destroy ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/decidim/lausanne/budgets/line_items_controller.rb', line 30 def destroy respond_to do |format| RemoveLineItem.call(current_order, project) do on(:ok) do |order| self.current_order = order format.html { redirect_back(fallback_location: lausanne_budget_path(budget)) } format.js { render "update_budget" } end on(:invalid) do render nothing: true, status: :unprocessable_entity end end end end |