mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #2516 from kristinalim/cleanup-move_admin_and_spree_from_routes
Separate admin and Spree routes from main file
This commit is contained in:
@@ -92,6 +92,12 @@ module Openfoodnetwork
|
||||
#{config.root}/app/jobs
|
||||
)
|
||||
|
||||
config.paths["config/routes"] = %w(
|
||||
config/routes.rb
|
||||
config/routes/admin.rb
|
||||
config/routes/spree.rb
|
||||
).map { |relative_path| Rails.root.join(relative_path) }
|
||||
|
||||
# Only load the plugins named here, in the order given (default is alphabetical).
|
||||
# :all can be used as a placeholder for all plugins not explicitly named.
|
||||
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
||||
|
||||
207
config/routes.rb
207
config/routes.rb
@@ -58,10 +58,6 @@ Openfoodnetwork::Application.routes.draw do
|
||||
resources :webhooks, only: [:create]
|
||||
end
|
||||
|
||||
namespace :admin do
|
||||
resources :bulk_line_items
|
||||
end
|
||||
|
||||
get '/checkout', :to => 'checkout#edit' , :as => :checkout
|
||||
put '/checkout', :to => 'checkout#update' , :as => :update_checkout
|
||||
get '/checkout/paypal_payment/:order_id', to: 'checkout#paypal_payment', as: :paypal_payment
|
||||
@@ -84,119 +80,6 @@ Openfoodnetwork::Application.routes.draw do
|
||||
get '/:id/shop', to: 'enterprises#shop', as: 'enterprise_shop'
|
||||
get "/enterprises/:permalink", to: redirect("/") # Legacy enterprise URL
|
||||
|
||||
namespace :admin do
|
||||
resources :order_cycles do
|
||||
post :bulk_update, on: :collection, as: :bulk_update
|
||||
|
||||
member do
|
||||
get :clone
|
||||
post :notify_producers
|
||||
end
|
||||
end
|
||||
|
||||
resources :enterprises do
|
||||
collection do
|
||||
get :for_order_cycle
|
||||
get :visible
|
||||
post :bulk_update, as: :bulk_update
|
||||
end
|
||||
|
||||
member do
|
||||
get :welcome
|
||||
put :register
|
||||
end
|
||||
|
||||
resources :producer_properties do
|
||||
post :update_positions, on: :collection
|
||||
end
|
||||
|
||||
resources :tag_rules, only: [:destroy]
|
||||
end
|
||||
|
||||
resources :manager_invitations, only: [:create]
|
||||
|
||||
resources :enterprise_relationships
|
||||
resources :enterprise_roles
|
||||
|
||||
resources :enterprise_fees do
|
||||
collection do
|
||||
get :for_order_cycle
|
||||
post :bulk_update, :as => :bulk_update
|
||||
end
|
||||
end
|
||||
|
||||
resources :enterprise_groups do
|
||||
get :move_up
|
||||
get :move_down
|
||||
end
|
||||
|
||||
get '/inventory', to: 'variant_overrides#index'
|
||||
|
||||
get '/product_import', to: 'product_import#index'
|
||||
post '/product_import', to: 'product_import#import'
|
||||
post '/product_import/validate_data', to: 'product_import#validate_data', as: 'product_import_process_async'
|
||||
post '/product_import/save_data', to: 'product_import#save_data', as: 'product_import_save_async'
|
||||
post '/product_import/reset_absent', to: 'product_import#reset_absent_products', as: 'product_import_reset_async'
|
||||
|
||||
resources :variant_overrides do
|
||||
post :bulk_update, on: :collection
|
||||
post :bulk_reset, on: :collection
|
||||
end
|
||||
|
||||
resources :inventory_items, only: [:create, :update]
|
||||
|
||||
resources :customers, only: [:index, :create, :update, :destroy, :show]
|
||||
|
||||
resources :tag_rules, only: [], format: :json do
|
||||
get :map_by_tag, on: :collection
|
||||
end
|
||||
|
||||
resource :content
|
||||
|
||||
resource :accounts_and_billing_settings, only: [:edit, :update] do
|
||||
collection do
|
||||
get :show_methods
|
||||
get :start_job
|
||||
end
|
||||
end
|
||||
|
||||
resource :business_model_configuration, only: [:edit, :update], controller: 'business_model_configuration'
|
||||
|
||||
resource :cache_settings
|
||||
|
||||
resource :account, only: [:show], controller: 'account'
|
||||
|
||||
resources :column_preferences, only: [], format: :json do
|
||||
put :bulk_update, on: :collection
|
||||
end
|
||||
|
||||
resource :invoice_settings, only: [:edit, :update]
|
||||
|
||||
resource :stripe_connect_settings, only: [:edit, :update]
|
||||
|
||||
resources :stripe_accounts, only: [:destroy] do
|
||||
get :connect, on: :collection
|
||||
get :status, on: :collection
|
||||
end
|
||||
|
||||
resources :schedules, only: [:index, :create, :update, :destroy], format: :json
|
||||
|
||||
resources :subscriptions, only: [:index, :new, :create, :edit, :update] do
|
||||
put :cancel, on: :member
|
||||
put :pause, on: :member
|
||||
put :unpause, on: :member
|
||||
end
|
||||
|
||||
resources :subscription_line_items, only: [], format: :json do
|
||||
post :build, on: :collection
|
||||
end
|
||||
|
||||
resources :proxy_orders, only: [:edit] do
|
||||
put :cancel, on: :member, format: :json
|
||||
put :resume, on: :member, format: :json
|
||||
end
|
||||
end
|
||||
|
||||
namespace :api do
|
||||
resources :enterprises do
|
||||
post :update_image, on: :member
|
||||
@@ -229,93 +112,3 @@ Openfoodnetwork::Application.routes.draw do
|
||||
mount Spree::Core::Engine, :at => '/'
|
||||
|
||||
end
|
||||
|
||||
|
||||
# Overriding Devise routes to use our own controller
|
||||
Spree::Core::Engine.routes.draw do
|
||||
devise_for :spree_user,
|
||||
:class_name => 'Spree::User',
|
||||
:controllers => { :sessions => 'spree/user_sessions',
|
||||
:registrations => 'user_registrations',
|
||||
:passwords => 'user_passwords',
|
||||
:confirmations => 'user_confirmations'},
|
||||
:skip => [:unlocks, :omniauth_callbacks],
|
||||
:path_names => { :sign_out => 'logout' },
|
||||
:path_prefix => :user
|
||||
end
|
||||
|
||||
|
||||
|
||||
Spree::Core::Engine.routes.prepend do
|
||||
match '/admin/reports/orders_and_distributors' => 'admin/reports#orders_and_distributors', :as => "orders_and_distributors_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/order_cycle_management' => 'admin/reports#order_cycle_management', :as => "order_cycle_management_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/packing' => 'admin/reports#packing', :as => "packing_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/group_buys' => 'admin/reports#group_buys', :as => "group_buys_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/bulk_coop' => 'admin/reports#bulk_coop', :as => "bulk_coop_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/payments' => 'admin/reports#payments', :as => "payments_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/orders_and_fulfillment' => 'admin/reports#orders_and_fulfillment', :as => "orders_and_fulfillment_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/users_and_enterprises' => 'admin/reports#users_and_enterprises', :as => "users_and_enterprises_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/sales_tax' => 'admin/reports#sales_tax', :as => "sales_tax_admin_reports", :via => [:get, :post]
|
||||
match '/admin/orders/bulk_management' => 'admin/orders#bulk_management', :as => "admin_bulk_order_management"
|
||||
match '/admin/reports/products_and_inventory' => 'admin/reports#products_and_inventory', :as => "products_and_inventory_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/customers' => 'admin/reports#customers', :as => "customers_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/xero_invoices' => 'admin/reports#xero_invoices', :as => "xero_invoices_admin_reports", :via => [:get, :post]
|
||||
match '/admin', :to => 'admin/overview#index', :as => :admin
|
||||
match '/admin/payment_methods/show_provider_preferences' => 'admin/payment_methods#show_provider_preferences', :via => :get
|
||||
put 'credit_cards/new_from_token', to: 'credit_cards#new_from_token'
|
||||
|
||||
resources :credit_cards
|
||||
|
||||
|
||||
namespace :api, :defaults => { :format => 'json' } do
|
||||
resources :users do
|
||||
get :authorise_api, on: :collection
|
||||
end
|
||||
|
||||
resources :products do
|
||||
collection do
|
||||
get :managed
|
||||
get :bulk_products
|
||||
get :overridable
|
||||
end
|
||||
delete :soft_delete
|
||||
post :clone
|
||||
|
||||
resources :variants do
|
||||
delete :soft_delete
|
||||
end
|
||||
end
|
||||
|
||||
resources :orders do
|
||||
get :managed, on: :collection
|
||||
end
|
||||
end
|
||||
|
||||
namespace :admin do
|
||||
get '/search/known_users' => "search#known_users", :as => :search_known_users
|
||||
get '/search/customers' => 'search#customers', :as => :search_customers
|
||||
get '/search/customer_addresses' => 'search#customer_addresses', :as => :search_customer_addresses
|
||||
|
||||
resources :products do
|
||||
get :product_distributions, on: :member
|
||||
get :group_buy_options, on: :member
|
||||
get :seo, on: :member
|
||||
|
||||
post :bulk_update, :on => :collection, :as => :bulk_update
|
||||
end
|
||||
|
||||
resources :orders do
|
||||
get :invoice, on: :member
|
||||
get :print, on: :member
|
||||
get :print_ticket, on: :member
|
||||
get :managed, on: :collection
|
||||
end
|
||||
end
|
||||
|
||||
resources :orders do
|
||||
get :clear, :on => :collection
|
||||
get :order_cycle_expired, :on => :collection
|
||||
put :cancel, on: :member
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
116
config/routes/admin.rb
Normal file
116
config/routes/admin.rb
Normal file
@@ -0,0 +1,116 @@
|
||||
Openfoodnetwork::Application.routes.draw do
|
||||
namespace :admin do
|
||||
resources :bulk_line_items
|
||||
|
||||
resources :order_cycles do
|
||||
post :bulk_update, on: :collection, as: :bulk_update
|
||||
|
||||
member do
|
||||
get :clone
|
||||
post :notify_producers
|
||||
end
|
||||
end
|
||||
|
||||
resources :enterprises do
|
||||
collection do
|
||||
get :for_order_cycle
|
||||
get :visible
|
||||
post :bulk_update, as: :bulk_update
|
||||
end
|
||||
|
||||
member do
|
||||
get :welcome
|
||||
put :register
|
||||
end
|
||||
|
||||
resources :producer_properties do
|
||||
post :update_positions, on: :collection
|
||||
end
|
||||
|
||||
resources :tag_rules, only: [:destroy]
|
||||
end
|
||||
|
||||
resources :manager_invitations, only: [:create]
|
||||
|
||||
resources :enterprise_relationships
|
||||
resources :enterprise_roles
|
||||
|
||||
resources :enterprise_fees do
|
||||
collection do
|
||||
get :for_order_cycle
|
||||
post :bulk_update, :as => :bulk_update
|
||||
end
|
||||
end
|
||||
|
||||
resources :enterprise_groups do
|
||||
get :move_up
|
||||
get :move_down
|
||||
end
|
||||
|
||||
get '/inventory', to: 'variant_overrides#index'
|
||||
|
||||
get '/product_import', to: 'product_import#index'
|
||||
post '/product_import', to: 'product_import#import'
|
||||
post '/product_import/validate_data', to: 'product_import#validate_data', as: 'product_import_process_async'
|
||||
post '/product_import/save_data', to: 'product_import#save_data', as: 'product_import_save_async'
|
||||
post '/product_import/reset_absent', to: 'product_import#reset_absent_products', as: 'product_import_reset_async'
|
||||
|
||||
resources :variant_overrides do
|
||||
post :bulk_update, on: :collection
|
||||
post :bulk_reset, on: :collection
|
||||
end
|
||||
|
||||
resources :inventory_items, only: [:create, :update]
|
||||
|
||||
resources :customers, only: [:index, :create, :update, :destroy, :show]
|
||||
|
||||
resources :tag_rules, only: [], format: :json do
|
||||
get :map_by_tag, on: :collection
|
||||
end
|
||||
|
||||
resource :content
|
||||
|
||||
resource :accounts_and_billing_settings, only: [:edit, :update] do
|
||||
collection do
|
||||
get :show_methods
|
||||
get :start_job
|
||||
end
|
||||
end
|
||||
|
||||
resource :business_model_configuration, only: [:edit, :update], controller: 'business_model_configuration'
|
||||
|
||||
resource :cache_settings
|
||||
|
||||
resource :account, only: [:show], controller: 'account'
|
||||
|
||||
resources :column_preferences, only: [], format: :json do
|
||||
put :bulk_update, on: :collection
|
||||
end
|
||||
|
||||
resource :invoice_settings, only: [:edit, :update]
|
||||
|
||||
resource :stripe_connect_settings, only: [:edit, :update]
|
||||
|
||||
resources :stripe_accounts, only: [:destroy] do
|
||||
get :connect, on: :collection
|
||||
get :status, on: :collection
|
||||
end
|
||||
|
||||
resources :schedules, only: [:index, :create, :update, :destroy], format: :json
|
||||
|
||||
resources :subscriptions, only: [:index, :new, :create, :edit, :update] do
|
||||
put :cancel, on: :member
|
||||
put :pause, on: :member
|
||||
put :unpause, on: :member
|
||||
end
|
||||
|
||||
resources :subscription_line_items, only: [], format: :json do
|
||||
post :build, on: :collection
|
||||
end
|
||||
|
||||
resources :proxy_orders, only: [:edit] do
|
||||
put :cancel, on: :member, format: :json
|
||||
put :resume, on: :member, format: :json
|
||||
end
|
||||
end
|
||||
end
|
||||
85
config/routes/spree.rb
Normal file
85
config/routes/spree.rb
Normal file
@@ -0,0 +1,85 @@
|
||||
# Overriding Devise routes to use our own controller
|
||||
Spree::Core::Engine.routes.draw do
|
||||
devise_for :spree_user,
|
||||
:class_name => 'Spree::User',
|
||||
:controllers => { :sessions => 'spree/user_sessions',
|
||||
:registrations => 'user_registrations',
|
||||
:passwords => 'user_passwords',
|
||||
:confirmations => 'user_confirmations'},
|
||||
:skip => [:unlocks, :omniauth_callbacks],
|
||||
:path_names => { :sign_out => 'logout' },
|
||||
:path_prefix => :user
|
||||
end
|
||||
|
||||
Spree::Core::Engine.routes.prepend do
|
||||
match '/admin/reports/orders_and_distributors' => 'admin/reports#orders_and_distributors', :as => "orders_and_distributors_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/order_cycle_management' => 'admin/reports#order_cycle_management', :as => "order_cycle_management_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/packing' => 'admin/reports#packing', :as => "packing_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/group_buys' => 'admin/reports#group_buys', :as => "group_buys_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/bulk_coop' => 'admin/reports#bulk_coop', :as => "bulk_coop_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/payments' => 'admin/reports#payments', :as => "payments_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/orders_and_fulfillment' => 'admin/reports#orders_and_fulfillment', :as => "orders_and_fulfillment_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/users_and_enterprises' => 'admin/reports#users_and_enterprises', :as => "users_and_enterprises_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/sales_tax' => 'admin/reports#sales_tax', :as => "sales_tax_admin_reports", :via => [:get, :post]
|
||||
match '/admin/orders/bulk_management' => 'admin/orders#bulk_management', :as => "admin_bulk_order_management"
|
||||
match '/admin/reports/products_and_inventory' => 'admin/reports#products_and_inventory', :as => "products_and_inventory_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/customers' => 'admin/reports#customers', :as => "customers_admin_reports", :via => [:get, :post]
|
||||
match '/admin/reports/xero_invoices' => 'admin/reports#xero_invoices', :as => "xero_invoices_admin_reports", :via => [:get, :post]
|
||||
match '/admin', :to => 'admin/overview#index', :as => :admin
|
||||
match '/admin/payment_methods/show_provider_preferences' => 'admin/payment_methods#show_provider_preferences', :via => :get
|
||||
put 'credit_cards/new_from_token', to: 'credit_cards#new_from_token'
|
||||
|
||||
resources :credit_cards
|
||||
|
||||
|
||||
namespace :api, :defaults => { :format => 'json' } do
|
||||
resources :users do
|
||||
get :authorise_api, on: :collection
|
||||
end
|
||||
|
||||
resources :products do
|
||||
collection do
|
||||
get :managed
|
||||
get :bulk_products
|
||||
get :overridable
|
||||
end
|
||||
delete :soft_delete
|
||||
post :clone
|
||||
|
||||
resources :variants do
|
||||
delete :soft_delete
|
||||
end
|
||||
end
|
||||
|
||||
resources :orders do
|
||||
get :managed, on: :collection
|
||||
end
|
||||
end
|
||||
|
||||
namespace :admin do
|
||||
get '/search/known_users' => "search#known_users", :as => :search_known_users
|
||||
get '/search/customers' => 'search#customers', :as => :search_customers
|
||||
get '/search/customer_addresses' => 'search#customer_addresses', :as => :search_customer_addresses
|
||||
|
||||
resources :products do
|
||||
get :product_distributions, on: :member
|
||||
get :group_buy_options, on: :member
|
||||
get :seo, on: :member
|
||||
|
||||
post :bulk_update, :on => :collection, :as => :bulk_update
|
||||
end
|
||||
|
||||
resources :orders do
|
||||
get :invoice, on: :member
|
||||
get :print, on: :member
|
||||
get :print_ticket, on: :member
|
||||
get :managed, on: :collection
|
||||
end
|
||||
end
|
||||
|
||||
resources :orders do
|
||||
get :clear, :on => :collection
|
||||
get :order_cycle_expired, :on => :collection
|
||||
put :cancel, on: :member
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user