diff --git a/app/controllers/providers_controller.rb b/app/controllers/providers_controller.rb index ceb78fd53..e97dc3371 100644 --- a/app/controllers/providers_controller.rb +++ b/app/controllers/providers_controller.rb @@ -383,13 +383,23 @@ def set_include end def set_provider - @provider = - Provider.unscoped.where( - "allocator.role_name IN ('ROLE_FOR_PROFIT_PROVIDER', 'ROLE_CONTRACTUAL_PROVIDER', 'ROLE_CONSORTIUM' , 'ROLE_CONSORTIUM_ORGANIZATION', 'ROLE_ALLOCATOR', 'ROLE_ADMIN', 'ROLE_MEMBER', 'ROLE_DEV')", - ). - where(deleted_at: nil). - where(symbol: params[:id]). - first + if params[:include_deleted] + @provider = + Provider.unscoped.where( + "allocator.role_name IN ('ROLE_FOR_PROFIT_PROVIDER', 'ROLE_CONTRACTUAL_PROVIDER', 'ROLE_CONSORTIUM' , 'ROLE_CONSORTIUM_ORGANIZATION', 'ROLE_ALLOCATOR', 'ROLE_ADMIN', 'ROLE_MEMBER', 'ROLE_DEV')", + ). + where(symbol: params[:id]). + first + else + @provider = + Provider.unscoped.where( + "allocator.role_name IN ('ROLE_FOR_PROFIT_PROVIDER', 'ROLE_CONTRACTUAL_PROVIDER', 'ROLE_CONSORTIUM' , 'ROLE_CONSORTIUM_ORGANIZATION', 'ROLE_ALLOCATOR', 'ROLE_ADMIN', 'ROLE_MEMBER', 'ROLE_DEV')", + ). + where(deleted_at: nil). + where(symbol: params[:id]). + first + end + fail ActiveRecord::RecordNotFound if @provider.blank? end diff --git a/app/controllers/v3/providers_controller.rb b/app/controllers/v3/providers_controller.rb index 9fcbdc097..8524c7d40 100644 --- a/app/controllers/v3/providers_controller.rb +++ b/app/controllers/v3/providers_controller.rb @@ -377,13 +377,23 @@ def set_include end def set_provider - @provider = - Provider.unscoped.where( - "allocator.role_name IN ('ROLE_FOR_PROFIT_PROVIDER', 'ROLE_CONTRACTUAL_PROVIDER', 'ROLE_CONSORTIUM' , 'ROLE_CONSORTIUM_ORGANIZATION', 'ROLE_ALLOCATOR', 'ROLE_ADMIN', 'ROLE_MEMBER', 'ROLE_DEV')", - ). - where(deleted_at: nil). - where(symbol: params[:id]). - first + if params[:include_deleted] + @provider = + Provider.unscoped.where( + "allocator.role_name IN ('ROLE_FOR_PROFIT_PROVIDER', 'ROLE_CONTRACTUAL_PROVIDER', 'ROLE_CONSORTIUM' , 'ROLE_CONSORTIUM_ORGANIZATION', 'ROLE_ALLOCATOR', 'ROLE_ADMIN', 'ROLE_MEMBER', 'ROLE_DEV')", + ). + where(symbol: params[:id]). + first + else + @provider = + Provider.unscoped.where( + "allocator.role_name IN ('ROLE_FOR_PROFIT_PROVIDER', 'ROLE_CONTRACTUAL_PROVIDER', 'ROLE_CONSORTIUM' , 'ROLE_CONSORTIUM_ORGANIZATION', 'ROLE_ALLOCATOR', 'ROLE_ADMIN', 'ROLE_MEMBER', 'ROLE_DEV')", + ). + where(deleted_at: nil). + where(symbol: params[:id]). + first + end + fail ActiveRecord::RecordNotFound if @provider.blank? end