mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Fix rubocop issues
This commit is contained in:
@@ -33,7 +33,8 @@ module Admin
|
||||
end
|
||||
|
||||
def edit
|
||||
@object = Enterprise.where(permalink: params[:id]).includes(users: [:ship_address, :bill_address]).first
|
||||
@object = Enterprise.where(permalink: params[:id]).
|
||||
includes(users: [:ship_address, :bill_address]).first
|
||||
super
|
||||
end
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ require 'open_food_network/enterprise_injection_data'
|
||||
module InjectionHelper
|
||||
include SerializerHelper
|
||||
|
||||
def inject_enterprises(enterprises = Enterprise.activated.includes(address: [:state, :country]).all)
|
||||
def inject_enterprises(enterprises = nil)
|
||||
inject_json_ams(
|
||||
"enterprises",
|
||||
enterprises,
|
||||
enterprises || default_enterprise_query,
|
||||
Api::EnterpriseSerializer,
|
||||
enterprise_injection_data
|
||||
)
|
||||
@@ -41,8 +41,14 @@ module InjectionHelper
|
||||
end
|
||||
|
||||
def inject_enterprise_and_relatives
|
||||
enterprises_and_relatives = current_distributor.
|
||||
relatives_including_self.
|
||||
activated.
|
||||
includes(address: [:state, :country]).
|
||||
all
|
||||
|
||||
inject_json_ams "enterprises",
|
||||
current_distributor.relatives_including_self.activated.includes(address: [:state, :country]).all,
|
||||
enterprises_and_relatives,
|
||||
Api::EnterpriseSerializer, enterprise_injection_data
|
||||
end
|
||||
|
||||
@@ -140,6 +146,10 @@ module InjectionHelper
|
||||
|
||||
private
|
||||
|
||||
def default_enterprise_query
|
||||
Enterprise.activated.includes(address: [:state, :country]).all
|
||||
end
|
||||
|
||||
def enterprise_injection_data
|
||||
@enterprise_injection_data ||= OpenFoodNetwork::EnterpriseInjectionData.new
|
||||
{ data: @enterprise_injection_data }
|
||||
|
||||
@@ -10,11 +10,11 @@ module Spree
|
||||
def available_countries
|
||||
checkout_zone = Zone.find_by_name(Spree::Config[:checkout_zone])
|
||||
|
||||
if checkout_zone && checkout_zone.kind == 'country'
|
||||
countries = checkout_zone.country_list
|
||||
else
|
||||
countries = Country.includes(:states).all
|
||||
end
|
||||
countries = if checkout_zone && checkout_zone.kind == 'country'
|
||||
checkout_zone.country_list
|
||||
else
|
||||
Country.includes(:states).all
|
||||
end
|
||||
|
||||
countries.collect do |country|
|
||||
country.name = Spree.t(country.iso, scope: 'country_names', default: country.name)
|
||||
|
||||
Reference in New Issue
Block a user