mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-04 22:16:08 +00:00
Merge pull request #5709 from luisramos0/empty
Replace empty? with blank? and replace unless empty? with if present?
This commit is contained in:
@@ -146,7 +146,7 @@ module Admin
|
||||
enterprises = OpenFoodNetwork::OrderCyclePermissions.new(spree_current_user, @order_cycle)
|
||||
.visible_enterprises
|
||||
|
||||
unless enterprises.empty?
|
||||
if enterprises.present?
|
||||
enterprises.includes(
|
||||
supplied_products:
|
||||
[:supplier, master: [:images], variants: { option_values: :option_type }]
|
||||
|
||||
@@ -241,7 +241,7 @@ class CheckoutController < Spree::StoreController
|
||||
def update_failed(error = RuntimeError.new(order_error))
|
||||
Bugsnag.notify(error)
|
||||
|
||||
flash[:error] = order_error if flash.empty?
|
||||
flash[:error] = order_error if flash.blank?
|
||||
checkout_failed
|
||||
update_failed_response
|
||||
end
|
||||
|
||||
@@ -26,7 +26,7 @@ module Spree
|
||||
def update_styles(params)
|
||||
if params[:new_attachment_styles].present?
|
||||
params[:new_attachment_styles].each do |_index, style|
|
||||
params[:attachment_styles][style[:name]] = style[:value] unless style[:value].empty?
|
||||
params[:attachment_styles][style[:name]] = style[:value] if style[:value].present?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,7 +38,7 @@ module Spree
|
||||
def update_headers(params)
|
||||
if params[:new_s3_headers].present?
|
||||
params[:new_s3_headers].each do |_index, header|
|
||||
params[:s3_headers][header[:name]] = header[:value] unless header[:value].empty?
|
||||
params[:s3_headers][header[:name]] = header[:value] if header[:value].present?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ module Spree
|
||||
end
|
||||
|
||||
def permitted_resource_params
|
||||
return params[:product] if params[:product].empty?
|
||||
return params[:product] if params[:product].blank?
|
||||
|
||||
params.require(:product).permit(::PermittedAttributes::Product.attributes)
|
||||
end
|
||||
|
||||
@@ -33,7 +33,7 @@ class UserRegistrationsController < Spree::UserRegistrationsController
|
||||
private
|
||||
|
||||
def spree_user_params
|
||||
return params[:spree_user] if params[:spree_user].empty?
|
||||
return params[:spree_user] if params[:spree_user].blank?
|
||||
|
||||
PermittedAttributes::User.new(params, :spree_user).call([:remember_me])
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ class Api::Admin::EnterpriseSerializer < ActiveModel::Serializer
|
||||
tag_group = find_match(tag_groups, tag_rule.preferred_customer_tags.
|
||||
split(",").
|
||||
map{ |t| { text: t } })
|
||||
if tag_group[:rules].empty?
|
||||
if tag_group[:rules].blank?
|
||||
tag_groups << tag_group
|
||||
tag_group[:position] = tag_groups.count
|
||||
end
|
||||
|
||||
@@ -3,6 +3,6 @@ class Api::Admin::UnitsVariantSerializer < ActiveModel::Serializer
|
||||
|
||||
def full_name
|
||||
full_name = object.full_name
|
||||
object.product.name + (full_name.empty? ? "" : ": #{full_name}")
|
||||
object.product.name + (full_name.blank? ? "" : ": #{full_name}")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ module PermittedAttributes
|
||||
end
|
||||
|
||||
def call
|
||||
return @params[:enterprise] if @params[:enterprise].empty?
|
||||
return @params[:enterprise] if @params[:enterprise].blank?
|
||||
|
||||
@params.require(:enterprise).permit(
|
||||
basic_permitted_attributes + [
|
||||
|
||||
@@ -7,7 +7,7 @@ module PermittedAttributes
|
||||
end
|
||||
|
||||
def call
|
||||
return @params[:order_cycle] if @params[:order_cycle].empty?
|
||||
return @params[:order_cycle] if @params[:order_cycle].blank?
|
||||
|
||||
@params.require(:order_cycle).permit(
|
||||
:name, :orders_open_at, :orders_close_at, :coordinator_id,
|
||||
|
||||
@@ -7,7 +7,7 @@ module PermittedAttributes
|
||||
end
|
||||
|
||||
def call
|
||||
return @params[:subscription] if @params[:subscription].empty?
|
||||
return @params[:subscription] if @params[:subscription].blank?
|
||||
|
||||
@params.require(:subscription).permit(basic_permitted_attributes + other_permitted_attributes)
|
||||
end
|
||||
|
||||
@@ -11,5 +11,5 @@
|
||||
%td.value
|
||||
= f.text_field :value, :class => 'autocomplete'
|
||||
%td.actions
|
||||
- unless @enterprise.producer_properties.empty?
|
||||
- if @enterprise.producer_properties.present?
|
||||
= link_to_remove_fields t(:remove), f, no_text: true, url: (f.object.persisted? && main_app.admin_enterprise_producer_property_path(@enterprise, f.object)), html: {"onclick" => "if(typeof(enterprise_form) != 'undefined') { angular.element(enterprise_form).scope().setFormDirty() }".html_safe}
|
||||
|
||||
Reference in New Issue
Block a user