mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-27 06:05:19 +00:00
Fix rubocop issues
This commit is contained in:
@@ -18,7 +18,6 @@ module Admin
|
||||
failure: lambda { render json: { errors: @schedule.errors.full_messages }, status: :unprocessable_entity }
|
||||
} }
|
||||
|
||||
|
||||
def index
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
|
||||
@@ -80,7 +80,7 @@ module Admin
|
||||
def collection
|
||||
if request.format.json?
|
||||
permissions.editable_standing_orders.ransack(params[:q]).result
|
||||
.preload([:shop, :customer, :schedule, :standing_line_items, :ship_address, :bill_address, proxy_orders: {order: :order_cycle}])
|
||||
.preload([:shop, :customer, :schedule, :standing_line_items, :ship_address, :bill_address, proxy_orders: { order: :order_cycle }])
|
||||
else
|
||||
StandingOrder.where("1=0")
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ module Admin
|
||||
def standing_orders_setup_complete?(shops)
|
||||
return false unless shops.any?
|
||||
shops = shops.select{ |shop| shipping_and_payment_methods_ok?(shop) && customers_ok?(shop) }
|
||||
Schedule.joins(:order_cycles).where(order_cycles: { coordinator_id: shops}).any?
|
||||
Schedule.joins(:order_cycles).where(order_cycles: { coordinator_id: shops }).any?
|
||||
end
|
||||
|
||||
def shipping_and_payment_methods_ok?(shop)
|
||||
|
||||
@@ -29,26 +29,26 @@ class StandingOrderMailer < Spree::BaseMailer
|
||||
def placement_summary_email(summary)
|
||||
@shop = Enterprise.find(summary.shop_id)
|
||||
@summary = summary
|
||||
mail(:to => @shop.email,
|
||||
:from => from_address,
|
||||
:subject => "#{Spree::Config[:site_name]} #{t('standing_order_mailer.placement_summary_email.subject')}")
|
||||
mail(to: @shop.email,
|
||||
from: from_address,
|
||||
subject: "#{Spree::Config[:site_name]} #{t('standing_order_mailer.placement_summary_email.subject')}")
|
||||
end
|
||||
|
||||
def confirmation_summary_email(summary)
|
||||
@shop = Enterprise.find(summary.shop_id)
|
||||
@summary = summary
|
||||
mail(:to => @shop.email,
|
||||
:from => from_address,
|
||||
:subject => "#{Spree::Config[:site_name]} #{t('standing_order_mailer.confirmation_summary_email.subject')}")
|
||||
mail(to: @shop.email,
|
||||
from: from_address,
|
||||
subject: "#{Spree::Config[:site_name]} #{t('standing_order_mailer.confirmation_summary_email.subject')}")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def send_mail(order)
|
||||
subject = "#{Spree::Config[:site_name]} #{t('order_mailer.confirm_email.subject')} ##{order.number}"
|
||||
mail(:to => order.email,
|
||||
:from => from_address,
|
||||
:subject => subject,
|
||||
:reply_to => order.distributor.email)
|
||||
mail(to: order.email,
|
||||
from: from_address,
|
||||
subject: subject,
|
||||
reply_to: order.distributor.email)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,9 +43,9 @@ Spree::Variant.class_eval do
|
||||
}
|
||||
|
||||
scope :in_schedule, lambda { |schedule|
|
||||
joins(exchanges: { order_cycle: :schedules}).
|
||||
joins(exchanges: { order_cycle: :schedules }).
|
||||
merge(Exchange.outgoing).
|
||||
where(schedules: { id: schedule}).
|
||||
where(schedules: { id: schedule }).
|
||||
select('DISTINCT spree_variants.*')
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ class StandingOrderValidator
|
||||
@available_variant_ids ||=
|
||||
Spree::Variant.joins(exchanges: { order_cycle: :schedules })
|
||||
.where(id: standing_line_items.map(&:variant_id))
|
||||
.where(schedules: { id: schedule}, exchanges: { incoming: false, receiver_id: shop })
|
||||
.where(schedules: { id: schedule }, exchanges: { incoming: false, receiver_id: shop })
|
||||
.merge(OrderCycle.not_closed)
|
||||
.select('DISTINCT spree_variants.id')
|
||||
.pluck(:id)
|
||||
|
||||
@@ -24,11 +24,11 @@ module OpenFoodNetwork
|
||||
attr_reader :params
|
||||
|
||||
def search_params
|
||||
{ :product_name_cont => params[:q], :sku_cont => params[:q] }
|
||||
{ product_name_cont: params[:q], sku_cont: params[:q] }
|
||||
end
|
||||
|
||||
def query_scope
|
||||
Spree::Variant.where(is_master: false).ransack(search_params.merge(:m => 'or')).result
|
||||
Spree::Variant.where(is_master: false).ransack(search_params.merge(m: 'or')).result
|
||||
end
|
||||
|
||||
def scope_to_schedule
|
||||
|
||||
Reference in New Issue
Block a user