Class: Decidim::Budgets::OrdersController

Inherits:
ApplicationController show all
Includes:
NeedsCurrentOrder
Defined in:
decidim-budgets/app/controllers/decidim/budgets/orders_controller.rb

Overview

Exposes the order resource so users can checkout it.

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_workflow, #show_votes_count?, #voting_finished?, #voting_open?

Methods inherited from Components::BaseController

#current_component, #current_manifest, #current_participatory_space, #permission_class_chain, #permission_scope, #redirect_unless_feature_private, #share_token

Methods included from RegistersPermissions

register_permissions

Methods included from UserBlockedChecker

#check_user_block_status, #check_user_not_blocked

Methods included from NeedsSnippets

#snippets

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from HasStoredPath

#skip_store_location?, #store_current_location

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#checkoutObject


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'decidim-budgets/app/controllers/decidim/budgets/orders_controller.rb', line 9

def checkout
  enforce_permission_to :vote, :project, order: current_order, budget: budget, workflow: current_workflow

  Checkout.call(current_order) do
    on(:ok) do
      flash[:notice] = I18n.t("orders.checkout.success", scope: "decidim")
      redirect_to budgets_path
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("orders.checkout.error", scope: "decidim")
      redirect_to budgets_path
    end
  end
end

#destroyObject


25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'decidim-budgets/app/controllers/decidim/budgets/orders_controller.rb', line 25

def destroy
  CancelOrder.call(current_order) do
    on(:ok) do
      flash[:notice] = I18n.t("orders.destroy.success", scope: "decidim")
      redirect_to redirect_path
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("orders.destroy.error", scope: "decidim")
      redirect_to redirect_path
    end
  end
end