Sha256: da61c6b18163abd6537e8186863539b3c579edbd5d92075ffe049ef8879bb5f0

Contents?: true

Size: 1.1 KB

Versions: 20

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Decidim
  module Budgets
    # Exposes the order resource so users can checkout it.
    class OrdersController < Decidim::Budgets::ApplicationController
      include NeedsCurrentOrder

      def checkout
        enforce_permission_to :vote, :project, order: current_order

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

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

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

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
decidim-budgets-0.22.0 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.21.0 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.20.1 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.20.0 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.19.1 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.18.1 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.19.0 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.17.2 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.18.0 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.17.1 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.16.1 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.17.0 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.16.0 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.15.2 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.15.1 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.15.0 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.14.4 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.14.3 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.14.2 app/controllers/decidim/budgets/orders_controller.rb
decidim-budgets-0.14.1 app/controllers/decidim/budgets/orders_controller.rb