Skip to content

Commit 8cd7c39

Browse files
Django Oscar Upgrade to version 3.2 (openedx-unsupported#4064)
* chore: django oscar version upgrade to 3.1 * fix: changed django migration to alter price field in stockrecord model chore: updated factory dependency refactor: updated field name feat: Mgmt Command to create mobile seats for new course runs (openedx-unsupported#4046) fix: skipped a failing test. Will fix it in another ticket fix: updated method refactor: made changes as per new version of oscar refactor: updated code to make voucher name unique fix: removed white spaces fix: removed white spaces refactor: changed code as per new version of oscar refactor: updated code fix: override Product model in catalogue app fix: removed extra spaces fix: updated code fix: changes in code to pass checks fix: changes in code to pass checks * feat: add data migration to make voucher names unique * fix: removed code * refactor: updated django oscar templates * refactor: updated price field name * refactor: update price field name * chore: PR to upgrade django oscar to version 3.2 * feat: resloved reserved keywords conflict * feat: add data mmigration to make basket_lineattribute value json compatible * feat: added refund functionality * feat: add data mmigration to make order_lineattribute value json compatible --------- Co-authored-by: Muhammad Umar Khan <[email protected]>
1 parent 7174f3f commit 8cd7c39

11 files changed

+187
-5
lines changed

db_keyword_overrides.yml

+5
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,10 @@ MYSQL:
1313
- ShippingEvent.lines
1414
- PaymentEvent.lines
1515
- ProductAlert.key
16+
- HistoricalOption.order
17+
- Option.order
1618
SNOWFLAKE:
19+
- HistoricalOption.order
20+
- Option.order
21+
1722
STITCH:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# -*- coding: utf-8 -*-
2+
from django.core.paginator import Paginator
3+
from django.db import migrations
4+
5+
6+
def make_lineattribute_value_json_compatible(apps, schema_editor):
7+
"""
8+
Makes line attribute value json compatible.
9+
"""
10+
LineAttribute = apps.get_model("basket", "LineAttribute")
11+
attributes = LineAttribute.objects.order_by('id')
12+
paginator = Paginator(attributes, 1000)
13+
14+
for page_number in paginator.page_range:
15+
page = paginator.page(page_number)
16+
updates = []
17+
18+
for obj in page.object_list:
19+
obj.value = '"{}"'.format(obj.value)
20+
updates.append(obj)
21+
22+
LineAttribute.objects.bulk_update(updates, ['value'])
23+
24+
25+
class Migration(migrations.Migration):
26+
27+
dependencies = [
28+
('basket', '0015_add_paymentintentid'),
29+
]
30+
31+
operations = [
32+
migrations.RunPython(make_lineattribute_value_json_compatible, migrations.RunPython.noop),
33+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 3.2.20 on 2023-12-05 10:34
2+
3+
import django.core.serializers.json
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('basket', '0016_make_lineattribute_value_json_compatible'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='lineattribute',
16+
name='value',
17+
field=models.JSONField(encoder=django.core.serializers.json.DjangoJSONEncoder, verbose_name='Value'),
18+
),
19+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Generated by Django 3.2.20 on 2023-12-05 10:34
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
import oscar.models.fields.slugfield
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('catalogue', '0056_auto_20231108_1355'),
12+
]
13+
14+
operations = [
15+
migrations.AlterModelOptions(
16+
name='option',
17+
options={'ordering': ['order', 'name'], 'verbose_name': 'Option', 'verbose_name_plural': 'Options'},
18+
),
19+
migrations.AddField(
20+
model_name='historicaloption',
21+
name='help_text',
22+
field=models.CharField(blank=True, help_text='Help text shown to the user on the add to basket form', max_length=255, null=True, verbose_name='Help text'),
23+
),
24+
migrations.AddField(
25+
model_name='historicaloption',
26+
name='option_group',
27+
field=models.ForeignKey(blank=True, db_constraint=False, help_text='Select an option group if using type "Option" or "Multi Option"', null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='catalogue.attributeoptiongroup', verbose_name='Option Group'),
28+
),
29+
migrations.AddField(
30+
model_name='historicaloption',
31+
name='order',
32+
field=models.IntegerField(blank=True, db_index=True, help_text='Controls the ordering of product options on product detail pages', null=True, verbose_name='Ordering'),
33+
),
34+
migrations.AddField(
35+
model_name='option',
36+
name='help_text',
37+
field=models.CharField(blank=True, help_text='Help text shown to the user on the add to basket form', max_length=255, null=True, verbose_name='Help text'),
38+
),
39+
migrations.AddField(
40+
model_name='option',
41+
name='option_group',
42+
field=models.ForeignKey(blank=True, help_text='Select an option group if using type "Option" or "Multi Option"', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='product_options', to='catalogue.attributeoptiongroup', verbose_name='Option Group'),
43+
),
44+
migrations.AddField(
45+
model_name='option',
46+
name='order',
47+
field=models.IntegerField(blank=True, db_index=True, help_text='Controls the ordering of product options on product detail pages', null=True, verbose_name='Ordering'),
48+
),
49+
migrations.AlterField(
50+
model_name='historicaloption',
51+
name='type',
52+
field=models.CharField(choices=[('text', 'Text'), ('integer', 'Integer'), ('boolean', 'True / False'), ('float', 'Float'), ('date', 'Date'), ('select', 'Select'), ('radio', 'Radio'), ('multi_select', 'Multi select'), ('checkbox', 'Checkbox')], default='text', max_length=255, verbose_name='Type'),
53+
),
54+
migrations.AlterField(
55+
model_name='historicalproduct',
56+
name='slug',
57+
field=oscar.models.fields.slugfield.SlugField(allow_unicode=True, max_length=255, verbose_name='Slug'),
58+
),
59+
migrations.AlterField(
60+
model_name='option',
61+
name='type',
62+
field=models.CharField(choices=[('text', 'Text'), ('integer', 'Integer'), ('boolean', 'True / False'), ('float', 'Float'), ('date', 'Date'), ('select', 'Select'), ('radio', 'Radio'), ('multi_select', 'Multi select'), ('checkbox', 'Checkbox')], default='text', max_length=255, verbose_name='Type'),
63+
),
64+
migrations.AlterField(
65+
model_name='product',
66+
name='slug',
67+
field=oscar.models.fields.slugfield.SlugField(allow_unicode=True, max_length=255, verbose_name='Slug'),
68+
),
69+
migrations.AlterUniqueTogether(
70+
name='productattribute',
71+
unique_together={('code', 'product_class')},
72+
),
73+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# -*- coding: utf-8 -*-
2+
from django.core.paginator import Paginator
3+
from django.db import migrations
4+
5+
6+
def make_lineattribute_value_json_compatible(apps, schema_editor):
7+
"""
8+
Makes line attribute value json compatible.
9+
"""
10+
LineAttribute = apps.get_model("order", "LineAttribute")
11+
attributes = LineAttribute.objects.order_by('id')
12+
paginator = Paginator(attributes, 1000)
13+
14+
for page_number in paginator.page_range:
15+
page = paginator.page(page_number)
16+
updates = []
17+
18+
for obj in page.object_list:
19+
obj.value = '"{}"'.format(obj.value)
20+
updates.append(obj)
21+
22+
LineAttribute.objects.bulk_update(updates, ['value'])
23+
24+
25+
class Migration(migrations.Migration):
26+
27+
dependencies = [
28+
('order', '0026_auto_20231108_1355'),
29+
]
30+
31+
operations = [
32+
migrations.RunPython(make_lineattribute_value_json_compatible, migrations.RunPython.noop),
33+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 3.2.20 on 2023-12-05 10:34
2+
3+
import django.core.serializers.json
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('order', '0027_make_lineattribute_value_json_compatible'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='lineattribute',
16+
name='value',
17+
field=models.JSONField(encoder=django.core.serializers.json.DjangoJSONEncoder, verbose_name='Value'),
18+
),
19+
]

requirements/base.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ django-libsass==0.9
168168
# via -r requirements/base.in
169169
django-model-utils==4.3.1
170170
# via edx-rbac
171-
django-oscar==3.1
171+
django-oscar==3.2
172172
# via
173173
# -c requirements/constraints.txt
174174
# -r requirements/base.in

requirements/constraints.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
cybersource-rest-client-python==0.0.21
1616

1717
# Django 3.2 support is added in version 2.2 so pinning it to 2.2
18-
django-oscar==3.1
18+
django-oscar==3.2
1919

2020
# Pinned because transifex-client==0.13.6 pins it
2121
urllib3>=1.24.2,<2.0.0

requirements/dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ django-model-utils==4.3.1
253253
# via
254254
# -r requirements/test.txt
255255
# edx-rbac
256-
django-oscar==3.1
256+
django-oscar==3.2
257257
# via -r requirements/test.txt
258258
django-phonenumber-field==5.0.0
259259
# via

requirements/production.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ django-libsass==0.9
171171
# via -r requirements/base.in
172172
django-model-utils==4.3.1
173173
# via edx-rbac
174-
django-oscar==3.1
174+
django-oscar==3.2
175175
# via
176176
# -c requirements/constraints.txt
177177
# -r requirements/base.in

requirements/test.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ django-model-utils==4.3.1
241241
# via
242242
# -r requirements/base.txt
243243
# edx-rbac
244-
django-oscar==3.1
244+
django-oscar==3.2
245245
# via
246246
# -c requirements/constraints.txt
247247
# -r requirements/base.txt

0 commit comments

Comments
 (0)