Skip to content

Commit

Permalink
Change unit_type warning to a hard error
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt-Yorkley committed Aug 21, 2018
1 parent 2275288 commit 78b1c51
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/models/product_import/entry_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def initialize(current_user, import_time, spreadsheet_data, editable_enterprises
def non_updatable_fields
{
category: :primary_taxon_id,
unit_type: :variant_unit_scale,
variant_unit_name: :variant_unit_name,
tax_category: :tax_category_id,
shipping_category: :shipping_category_id
Expand Down Expand Up @@ -178,6 +177,11 @@ def product_validation(entry)
return
end

if existing_product.variant_unit_scale != entry.variant_unit_scale
mark_as_invalid(entry, attribute: "unit_type", error: I18n.t('admin.product_import.model.not_updatable'))
return
end

# Otherwise, if a variant exists with matching display_name and unit_value, update it
existing_product.variants.each do |existing_variant|
if entry_matches_existing_variant?(entry, existing_variant) && existing_variant.deleted_at.nil?
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ en:
conditional_blank: can't be blank if unit_type is blank
no_product: did not match any products in the database
not_found: not found in database
not_updatable: cannot be updated on existing products
not_updatable: cannot be updated on existing products via product import
blank: can't be blank
products_no_permission: you do not have permission to manage products for this enterprise
inventory_no_permission: you do not have permission to create inventory for this producer
Expand Down

0 comments on commit 78b1c51

Please sign in to comment.