mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Adjust namespace and scope for routes
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Controller used to provide the API products for the DFC application
|
||||
module Api
|
||||
module DfcProvider
|
||||
class ProductsController < Api::BaseController
|
||||
module DfcProvider
|
||||
module Api
|
||||
class ProductsController < ::Api::BaseController
|
||||
skip_before_filter :authenticate_user
|
||||
before_filter :set_enterprise
|
||||
before_filter :authenticate_user
|
||||
skip_authorization_check
|
||||
|
||||
def index
|
||||
products = @enterprise.
|
||||
@@ -20,6 +23,10 @@ module Api
|
||||
|
||||
private
|
||||
|
||||
def authenticate_user
|
||||
@current_api_user = @enterprise.owner
|
||||
end
|
||||
|
||||
def set_enterprise
|
||||
@enterprise = ::Enterprise.find(params[:enterprise_id])
|
||||
end
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
DfcProvider::Engine.routes.draw do
|
||||
namespace :api do
|
||||
namespace :dfc_provider do
|
||||
scope :dfc_provider, as: :dfc_provider, path: '/dfc_provider' do
|
||||
resources :enterprises, only: :none do
|
||||
resources :products, only: %i[index]
|
||||
end
|
||||
|
||||
@@ -13,6 +13,6 @@ Gem::Specification.new do |s|
|
||||
s.email = ['admin@openfoodfrance.org']
|
||||
s.summary = 'Provides an API stack implementing DFC semantic specifications'
|
||||
|
||||
s.files = Dir["{app,config,db,lib}/**/*"] + ['MIT-LICENSE', 'Rakefile', 'README.rdoc']
|
||||
s.files = Dir["{app,config,db,lib}/**/*"] + ['README.rdoc']
|
||||
s.test_files = Dir['test/**/*']
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user