Commit ea8c9629 by ivan Lan

Fix the class_varibale problem for Controller::Base by a crude way

parent 81f27000
module Shotengai
module Controller
module Customer
class OrdersController < Shotengai::Controller::Base
self.resources = Cart
self.template_dir = 'shotengai/customer/orders/'
remove_actions
index_query do |resource, params|
resource.status_is(params[:status])
end
def add_to_cart
buyer_type, buyer_id = add_to_cart_params.values_at(:buyer_type, :buyer_id)
buyer = buyer_type.constantize.find(buyer_id)
@snapshot = buyer.order_cart.snapshots.create!(add_to_cart_params)
head 201
end
def create_by_snapshot
end
def create_directly
end
def pay
@resource.pay!
respond_with @resource, template: "#{@@template_dir}/show"
end
def cancel
@resource.cancel!
respond_with @resource, template: "#{@@template_dir}/show"
end
def get_it
@resource.get_it
respond_with @resource, template: "#{@@template_dir}/show"
end
private
def resource_params
params.require(resource_key).permit(
:address, :customer_remark, snapshot_ids: []
)
end
def add_to_cart_params
params.require(:snapshot).permit(
:series_id, :count, :buyer_type, :buyer_id
)
end
end
end
end
end
......@@ -11,7 +11,10 @@ module Shotengai
skip_before_action :set_resource, only: [:cart, :add_to_cart, :create_directly]
remove_actions :destroy
default_query do |resource, params|
end
index_query do |resource, params|
resource.status_is(params[:status])
end
......
......@@ -11,8 +11,9 @@ module Shotengai
params[:product_id] && { shotengai_product_id: params[:product_id] }
)
end
private
index_query do |resource, params|
end
end
end
end
......
......@@ -6,6 +6,9 @@ module Shotengai
self.template_dir = 'shotengai/customer/products/'
remove_actions :create, :update, :destroy
default_query do |resource, params|
end
index_query do |resource, params|
params[:catalog_list] ?
......
......@@ -6,7 +6,11 @@ module Shotengai
self.template_dir = 'shotengai/merchant/orders/'
remove_actions :create, :destroy
default_query do |resource, params|
end
index_query do |resource, params|
resource.status_is(params[:status])
end
......
......@@ -11,6 +11,10 @@ module Shotengai
)
end
index_query do |resource, params|
end
private
def resource_params
spec = params.require(resource_key).fetch(:spec, nil).try(:permit!)
......
......@@ -5,6 +5,10 @@ module Shotengai
self.resources = Product
self.template_dir = 'shotengai/merchant/products/'
default_query do |resource, params|
end
index_query do |resource, params|
params[:catalog_list] ?
resource.tagged_with(params[:catalog_list], on: :catalogs) :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment