Skip to content

Commit

Permalink
Gaaf
Browse files Browse the repository at this point in the history
  • Loading branch information
viggo-devries committed Dec 20, 2023
1 parent cdc2b3c commit af698d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
18 changes: 9 additions & 9 deletions oscar_odin/mappings/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,32 +115,32 @@ def save_many_to_many(context, errors):


def save_attributes(instances):
attributes_to_update = []
attributes_to_create = []
attributes_to_delete = []
attributes_to_update = []
fields_to_be_updated = set()

for product in instances:
product.attr.invalidate()
(
to_be_deleted,
update_fields,
to_be_updated,
to_be_created,
to_be_deleted,
update_fields,
) = product.attr.prepare_save()

if to_be_deleted:
attributes_to_delete.extend(to_be_deleted)

if update_fields:
fields_to_be_updated.update(update_fields)

if to_be_updated:
attributes_to_update.extend(to_be_updated)

if to_be_created:
attributes_to_create.extend(to_be_created)

if to_be_deleted:
attributes_to_delete.extend(to_be_deleted)

if update_fields:
fields_to_be_updated.update(update_fields)

# now save all the attributes in bulk
if attributes_to_delete:
ProductAttributeValue.objects.filter(pk__in=attributes_to_delete).delete()
Expand Down
1 change: 0 additions & 1 deletion tests/mappings/test_catalogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ def test_product_to_resource__where_is_a_parent_product_do_not_include_children(
actual = catalogue.product_to_resource(product)

self.assertEqual(product.title, actual.title)
self.assertIsNone(actual.children)

0 comments on commit af698d6

Please sign in to comment.