mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Move enterprises api controller out of spree namespace
This commit is contained in:
10
app/controllers/api/enterprises_controller.rb
Normal file
10
app/controllers/api/enterprises_controller.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
module Api
|
||||
class EnterprisesController < Spree::Api::BaseController
|
||||
respond_to :json
|
||||
|
||||
def managed
|
||||
@enterprises = Enterprise.ransack(params[:q]).result.managed_by(current_api_user)
|
||||
respond_with(@enterprises)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,12 +0,0 @@
|
||||
module Spree
|
||||
module Api
|
||||
class EnterprisesController < Spree::Api::BaseController
|
||||
respond_to :json
|
||||
|
||||
def managed
|
||||
@enterprises = Enterprise.ransack(params[:q]).result.managed_by(current_api_user)
|
||||
respond_with(@enterprises)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
2
app/views/api/enterprises/bulk_index.v1.rabl
Normal file
2
app/views/api/enterprises/bulk_index.v1.rabl
Normal file
@@ -0,0 +1,2 @@
|
||||
collection @enterprises
|
||||
extends "api/enterprises/bulk_show"
|
||||
@@ -2,8 +2,8 @@ object @order_cycle
|
||||
|
||||
attributes :id, :name
|
||||
node( :suppliers ) do |oc|
|
||||
partial 'spree/api/enterprises/bulk_index', :object => oc.suppliers
|
||||
partial 'api/enterprises/bulk_index', :object => oc.suppliers
|
||||
end
|
||||
node( :distributors ) do |oc|
|
||||
partial 'spree/api/enterprises/bulk_index', :object => oc.distributors
|
||||
partial 'api/enterprises/bulk_index', :object => oc.distributors
|
||||
end
|
||||
@@ -1,2 +0,0 @@
|
||||
collection @enterprises
|
||||
extends "spree/api/enterprises/bulk_show"
|
||||
@@ -1,5 +1,5 @@
|
||||
object @line_item
|
||||
attributes :id, :quantity, :max_quantity
|
||||
node( :supplier ) { |li| partial 'spree/api/enterprises/bulk_show', :object => li.product.supplier }
|
||||
node( :supplier ) { |li| partial 'api/enterprises/bulk_show', :object => li.product.supplier }
|
||||
node( :units_product ) { |li| partial 'spree/api/products/units_show', :object => li.product }
|
||||
node( :units_variant ) { |li| partial 'spree/api/variants/units_show', :object => li.variant }
|
||||
@@ -5,7 +5,7 @@ node( :full_name ) { |order| order.billing_address.nil? ? "" : ( order.billing_a
|
||||
node( :email ) { |order| order.email || "" }
|
||||
node( :phone ) { |order| order.billing_address.nil? ? "a" : ( order.billing_address.phone || "" ) }
|
||||
node( :completed_at ) { |order| order.completed_at.blank? ? "" : order.completed_at.strftime("%F %T") }
|
||||
node( :distributor ) { |order| partial 'spree/api/enterprises/bulk_show', :object => order.distributor }
|
||||
node( :distributor ) { |order| partial 'api/enterprises/bulk_show', :object => order.distributor }
|
||||
node( :order_cycle ) { |order| partial 'api/order_cycles/bulk_show', :object => order.order_cycle }
|
||||
node( :line_items ) do |order|
|
||||
order.line_items.order('id ASC').map do |line_item|
|
||||
|
||||
@@ -8,7 +8,7 @@ node( :price ) { |p| p.price.nil? ? '0.0' : p.price }
|
||||
node( :available_on ) { |p| p.available_on.blank? ? "" : p.available_on.strftime("%F %T") }
|
||||
node( :permalink_live ) { |p| p.permalink }
|
||||
node( :supplier ) do |p|
|
||||
partial 'spree/api/enterprises/bulk_show', :object => p.supplier
|
||||
partial 'api/enterprises/bulk_show', :object => p.supplier
|
||||
end
|
||||
node( :variants ) do |p|
|
||||
partial 'spree/api/variants/bulk_index', :object => p.variants.reorder('spree_variants.id ASC')
|
||||
|
||||
@@ -49,6 +49,9 @@ Openfoodnetwork::Application.routes.draw do
|
||||
end
|
||||
|
||||
namespace :api do
|
||||
resources :enterprises do
|
||||
get :managed, on: :collection
|
||||
end
|
||||
resources :order_cycles do
|
||||
get :managed, on: :collection
|
||||
end
|
||||
@@ -107,10 +110,6 @@ Spree::Core::Engine.routes.prepend do
|
||||
resources :orders do
|
||||
get :managed, on: :collection
|
||||
end
|
||||
|
||||
resources :enterprises do
|
||||
get :managed, on: :collection
|
||||
end
|
||||
end
|
||||
|
||||
namespace :admin do
|
||||
|
||||
Reference in New Issue
Block a user