mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-06 02:51:34 +00:00
Fix some rubocop issues in order_and_distributor_report
This commit is contained in:
@@ -114,7 +114,6 @@ Metrics/LineLength:
|
||||
- lib/open_food_network/enterprise_issue_validator.rb
|
||||
- lib/open_food_network/group_buy_report.rb
|
||||
- lib/open_food_network/lettuce_share_report.rb
|
||||
- lib/open_food_network/order_and_distributor_report.rb
|
||||
- lib/open_food_network/order_cycle_form_applicator.rb
|
||||
- lib/open_food_network/order_cycle_management_report.rb
|
||||
- lib/open_food_network/payments_report.rb
|
||||
|
||||
@@ -42,15 +42,17 @@ module OpenFoodNetwork
|
||||
|
||||
orders = search.result
|
||||
|
||||
# If empty array is passed in, the where clause will return all line_items, which is bad
|
||||
orders_with_hidden_details =
|
||||
@permissions.editable_orders.empty? ? orders : orders.where('spree_orders.id NOT IN (?)', @permissions.editable_orders)
|
||||
|
||||
orders.select{ |order| orders_with_hidden_details.include? order }.each do |order|
|
||||
orders.select{ |order| orders_with_hidden_details(orders).include? order }.each do |order|
|
||||
# TODO We should really be hiding customer code here too, but until we
|
||||
# have an actual association between order and customer, it's a bit tricky
|
||||
order.bill_address.andand.assign_attributes(firstname: I18n.t('admin.reports.hidden'), lastname: "", phone: "", address1: "", address2: "", city: "", zipcode: "", state: nil)
|
||||
order.ship_address.andand.assign_attributes(firstname: I18n.t('admin.reports.hidden'), lastname: "", phone: "", address1: "", address2: "", city: "", zipcode: "", state: nil)
|
||||
order.bill_address.andand.
|
||||
assign_attributes(firstname: I18n.t('admin.reports.hidden'),
|
||||
lastname: "", phone: "", address1: "", address2: "",
|
||||
city: "", zipcode: "", state: nil)
|
||||
order.ship_address.andand.
|
||||
assign_attributes(firstname: I18n.t('admin.reports.hidden'),
|
||||
lastname: "", phone: "", address1: "", address2: "",
|
||||
city: "", zipcode: "", state: nil)
|
||||
order.assign_attributes(email: I18n.t('admin.reports.hidden'))
|
||||
end
|
||||
|
||||
@@ -59,6 +61,17 @@ module OpenFoodNetwork
|
||||
|
||||
private
|
||||
|
||||
def orders_with_hidden_details(orders)
|
||||
# If empty array is passed in, the where clause will return all line_items, which is bad
|
||||
if @permissions.editable_orders.empty?
|
||||
orders
|
||||
else
|
||||
orders.
|
||||
where('spree_orders.id NOT IN (?)',
|
||||
@permissions.editable_orders)
|
||||
end
|
||||
end
|
||||
|
||||
def line_item_details(orders)
|
||||
order_and_distributor_details = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user