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

Commit

Permalink
feat: make basket_lineattribute value json compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
mumarkhan999 committed Dec 7, 2023
1 parent 700cc13 commit 8cd546f
Showing 1 changed file with 33 additions and 0 deletions.
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


def make_lineattribute_value_json_compatible(apps, schema_editor):
"""
Makes line attribute value json compatible.
"""
LineAttribute = apps.get_model("basket", "LineAttribute")
attributes = LineAttribute.objects.order_by('id')
paginator = Paginator(attributes, 1000)

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

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

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


class Migration(migrations.Migration):

dependencies = [
('voucher', '0015_add_paymentintentid'),
]

operations = [
migrations.RunPython(make_lineattribute_value_json_compatible, migrations.RunPython.noop),
]

0 comments on commit 8cd546f

Please sign in to comment.