Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

feat: make basket_lineattribute value json compatible #4071

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
from django.core.paginator import Paginator
from django.db import migrations

Check warning on line 3 in ecommerce/extensions/basket/migrations/0016_make_lineattribute_value_json_compatible.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/basket/migrations/0016_make_lineattribute_value_json_compatible.py#L2-L3

Added lines #L2 - L3 were not covered by tests


def make_lineattribute_value_json_compatible(apps, schema_editor):

Check warning on line 6 in ecommerce/extensions/basket/migrations/0016_make_lineattribute_value_json_compatible.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/basket/migrations/0016_make_lineattribute_value_json_compatible.py#L6

Added line #L6 was not covered by tests
"""
Makes line attribute value json compatible.
"""
LineAttribute = apps.get_model("basket", "LineAttribute")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test for this migration

attributes = LineAttribute.objects.order_by('id')
paginator = Paginator(attributes, 1000)

Check warning on line 12 in ecommerce/extensions/basket/migrations/0016_make_lineattribute_value_json_compatible.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/basket/migrations/0016_make_lineattribute_value_json_compatible.py#L10-L12

Added lines #L10 - L12 were not covered by tests

for page_number in paginator.page_range:
page = paginator.page(page_number)
updates = []

Check warning on line 16 in ecommerce/extensions/basket/migrations/0016_make_lineattribute_value_json_compatible.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/basket/migrations/0016_make_lineattribute_value_json_compatible.py#L14-L16

Added lines #L14 - L16 were not covered by tests

for obj in page.object_list:
obj.value = '"{}"'.format(obj.value)
updates.append(obj)

Check warning on line 20 in ecommerce/extensions/basket/migrations/0016_make_lineattribute_value_json_compatible.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/basket/migrations/0016_make_lineattribute_value_json_compatible.py#L18-L20

Added lines #L18 - L20 were not covered by tests

LineAttribute.objects.bulk_update(updates, ['value'])

Check warning on line 22 in ecommerce/extensions/basket/migrations/0016_make_lineattribute_value_json_compatible.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/basket/migrations/0016_make_lineattribute_value_json_compatible.py#L22

Added line #L22 was not covered by tests


class Migration(migrations.Migration):

Check warning on line 25 in ecommerce/extensions/basket/migrations/0016_make_lineattribute_value_json_compatible.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/basket/migrations/0016_make_lineattribute_value_json_compatible.py#L25

Added line #L25 was not covered by tests

dependencies = [

Check warning on line 27 in ecommerce/extensions/basket/migrations/0016_make_lineattribute_value_json_compatible.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/basket/migrations/0016_make_lineattribute_value_json_compatible.py#L27

Added line #L27 was not covered by tests
('basket', '0015_add_paymentintentid'),
]

operations = [

Check warning on line 31 in ecommerce/extensions/basket/migrations/0016_make_lineattribute_value_json_compatible.py

View check run for this annotation

Codecov / codecov/patch

ecommerce/extensions/basket/migrations/0016_make_lineattribute_value_json_compatible.py#L31

Added line #L31 was not covered by tests
migrations.RunPython(make_lineattribute_value_json_compatible, migrations.RunPython.noop),
]
Loading