mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Move attribute check to method
This commit is contained in:
@@ -314,7 +314,7 @@ module ProductImport
|
||||
def product_field_errors(entry, existing_product)
|
||||
EntryValidator.non_updatable_fields.each do |display_name, attribute|
|
||||
next if attributes_match?(attribute, existing_product, entry) || attributes_blank?(attribute, existing_product, entry)
|
||||
next if attribute == :description
|
||||
next if ignore_when_updating_product?(attribute)
|
||||
mark_as_invalid(entry, attribute: display_name, error: I18n.t('admin.product_import.model.not_updatable'))
|
||||
end
|
||||
end
|
||||
@@ -325,6 +325,11 @@ module ProductImport
|
||||
existing_product_value == convert_to_trusted_type(entry_value, existing_product_value)
|
||||
end
|
||||
|
||||
def ignore_when_updating_product?(attribute)
|
||||
attributes_to_ignore = [:description]
|
||||
attributes_to_ignore.include? attribute
|
||||
end
|
||||
|
||||
def convert_to_trusted_type(untrusted_attribute, trusted_attribute)
|
||||
case trusted_attribute
|
||||
when Integer
|
||||
|
||||
Reference in New Issue
Block a user