Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zubair django oscar31 test pr2 #4142

Draft
wants to merge 24 commits into
base: 2u/main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
58f1e3f
# This is a combination of 2 commits.
zubair-ce07 Nov 12, 2023
819eaa8
parent 77569a72d59bebede624fccf345aab0c32e02f29
zubair-ce07 Feb 28, 2024
9b4d740
refactor: Add course info to Stripe Payment Intent metadata (#4100)
julianajlk Jan 19, 2024
ba09a9f
Revert "refactor: Add course info to Stripe Payment Intent metadata" …
julianajlk Jan 22, 2024
e27cb14
refactor: Add courses metadata from basket to Stripe Payment Intent (…
julianajlk Jan 26, 2024
9fd6eb3
feat: Update ios product price on price change from discovery (#4118)
jawad-khan Feb 9, 2024
8b2f81c
[Copy]Django Oscar Upgrade to version 3.1 (#4102)
zubair-ce07 Feb 13, 2024
417ea55
Cpappas/revert oscar 3.1 (#4128)
christopappas Feb 13, 2024
108795f
Fix: Support create-mobile-skus to run again if failed (#4129)
jawad-khan Feb 15, 2024
a8e939f
fix: Enable enrollment code purchase with mobile seats (#4130)
moeez96 Feb 16, 2024
a04b13f
fix: Fix send email error and add tests (#4135)
moeez96 Feb 22, 2024
499d1fa
Management command to update voucher names and make them unique (#4134)
zubair-ce07 Feb 23, 2024
ad23224
feat: update_voucher_names now can be run synchronously and can batch…
christopappas Feb 26, 2024
cf759d0
fix: price field name
zubair-ce07 Feb 28, 2024
36f26ca
fix: unique voucher name
zubair-ce07 Feb 28, 2024
bc43d4d
fix: white space
zubair-ce07 Feb 28, 2024
1b774a8
fix: unique voucher name
zubair-ce07 Feb 28, 2024
a54f377
fix: unique voucher name
zubair-ce07 Feb 28, 2024
3afb947
refactor: Add course info to Stripe Payment Intent metadata (#4100)
julianajlk Jan 19, 2024
e60cf61
fix: merge conflicts
zubair-ce07 Feb 28, 2024
5e8e013
fix: unique voucher names
zubair-ce07 Feb 29, 2024
3e7cf18
fix: updated code
zubair-ce07 Feb 29, 2024
6aa7e8d
fix: new line
zubair-ce07 Feb 29, 2024
ae5448d
Merge branch '2u/main' into zubair-django-oscar31-test-PR2
zubair-ce07 Mar 1, 2024
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
4 changes: 2 additions & 2 deletions ecommerce/extensions/api/v2/tests/views/test_publication.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,11 @@ def assert_seat_saved(self, course, expected, test_mobile_seats=False):
if test_mobile_seats and verified_product:
android_seat = course.seat_products.get(title='Android ' + seat_title)
self.assertEqual(android_seat.expires, expires)
self.assertEqual(android_seat.stockrecords.get(partner=self.partner).price_excl_tax, expected['price'])
self.assertEqual(android_seat.stockrecords.get(partner=self.partner).price, expected['price'])

ios_seat = course.seat_products.get(title='Ios ' + seat_title)
self.assertEqual(ios_seat.expires, expires)
self.assertEqual(ios_seat.stockrecords.get(partner=self.partner).price_excl_tax, expected['price'])
self.assertEqual(ios_seat.stockrecords.get(partner=self.partner).price, expected['price'])

return seat

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Generated by Django 3.2.20 on 2024-02-14 12:43

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('catalogue', '0057_add_app_store_id_product_attr'),
]

operations = [
migrations.AlterModelOptions(
name='option',
options={'ordering': ['name'], 'verbose_name': 'Option', 'verbose_name_plural': 'Options'},
),
migrations.AddField(
model_name='category',
name='meta_description',
field=models.TextField(blank=True, null=True, verbose_name='Meta description'),
),
migrations.AddField(
model_name='category',
name='meta_title',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Meta title'),
),
migrations.AddField(
model_name='historicalcategory',
name='meta_description',
field=models.TextField(blank=True, null=True, verbose_name='Meta description'),
),
migrations.AddField(
model_name='historicalcategory',
name='meta_title',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Meta title'),
),
migrations.AddField(
model_name='historicaloption',
name='required',
field=models.BooleanField(default=False, verbose_name='Is this option required?'),
),
migrations.AddField(
model_name='historicalproduct',
name='meta_description',
field=models.TextField(blank=True, null=True, verbose_name='Meta description'),
),
migrations.AddField(
model_name='historicalproduct',
name='meta_title',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Meta title'),
),
migrations.AddField(
model_name='option',
name='required',
field=models.BooleanField(default=False, verbose_name='Is this option required?'),
),
migrations.AddField(
model_name='product',
name='meta_description',
field=models.TextField(blank=True, null=True, verbose_name='Meta description'),
),
migrations.AddField(
model_name='product',
name='meta_title',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Meta title'),
),
migrations.AlterField(
model_name='historicaloption',
name='name',
field=models.CharField(db_index=True, max_length=128, verbose_name='Name'),
),
migrations.AlterField(
model_name='historicaloption',
name='type',
field=models.CharField(choices=[('text', 'Text'), ('integer', 'Integer'), ('boolean', 'True / False'), ('float', 'Float'), ('date', 'Date')], default='text', max_length=255, verbose_name='Type'),
),
migrations.AlterField(
model_name='historicalproductattributevalue',
name='value_boolean',
field=models.BooleanField(blank=True, db_index=True, null=True, verbose_name='Boolean'),
),
migrations.AlterField(
model_name='option',
name='name',
field=models.CharField(db_index=True, max_length=128, verbose_name='Name'),
),
migrations.AlterField(
model_name='option',
name='type',
field=models.CharField(choices=[('text', 'Text'), ('integer', 'Integer'), ('boolean', 'True / False'), ('float', 'Float'), ('date', 'Date')], default='text', max_length=255, verbose_name='Type'),
),
migrations.AlterField(
model_name='productattributevalue',
name='value_boolean',
field=models.BooleanField(blank=True, db_index=True, null=True, verbose_name='Boolean'),
),
]
1 change: 0 additions & 1 deletion ecommerce/extensions/payment/processors/stripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ def get_capture_context(self, request):
# don't create a new intent for the same basket
idempotency_key=self.generate_basket_pi_idempotency_key(basket),
)

# id is the payment_intent_id from Stripe
transaction_id = stripe_response['id']

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ class ManagementCommandTests(TestCase):
def setUp(self):
self.voucher_name = 'Test voucher'
self.data = {
'name': self.voucher_name,
'start_datetime': timezone.now(),
'end_datetime': timezone.now() + timedelta(days=7)
}

for item in range(3):
code = 'TESTCODE' + str(item)
Voucher.objects.create(code=code, **self.data)
name = self.voucher_name + str(item)
Voucher.objects.create(name=name, code=code, **self.data)

self.LOGGER_NAME = 'ecommerce.extensions.voucher.management.commands.update_voucher_names'

Expand All @@ -43,7 +44,7 @@ def test_update_voucher_names_task(self):
assert vouchers.count() == 3

for voucher in vouchers:
assert voucher.name == f'{voucher.id} - {self.voucher_name}'
assert voucher.name[:-1] == f'{voucher.id} - {self.voucher_name}'

@mock.patch('ecommerce.extensions.voucher.tasks.update_voucher_names_task.delay')
def test_update_voucher_names_synchronous(self, mock_delay):
Expand All @@ -57,7 +58,7 @@ def test_update_voucher_names_synchronous(self, mock_delay):
assert vouchers.count() == 3

for voucher in vouchers:
assert voucher.name == f'{voucher.id} - {self.voucher_name}'
assert voucher.name[:-1] == f'{voucher.id} - {self.voucher_name}'

mock_delay.assert_not_called()

Expand Down Expand Up @@ -114,15 +115,15 @@ def test_voucher_name_update_idempotent(self):
vouchers = Voucher.objects.all()
assert vouchers.count() == 3
for voucher in vouchers:
assert voucher.name == self.voucher_name
assert voucher.name[:-1] == self.voucher_name

# And after each time we run the command
for _ in range(2):
call_command('update_voucher_names', run_async=True)

vouchers = Voucher.objects.all()
for voucher in vouchers:
assert voucher.name == f'{voucher.id} - {self.voucher_name}'
assert voucher.name[:-1] == f'{voucher.id} - {self.voucher_name}'

@mock.patch('ecommerce.extensions.voucher.tasks.update_voucher_names_task.delay')
def test_update_voucher_names_command_failure(self, mock_delay):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by Django 3.2.20 on 2023-11-14 11:20

from django.core.paginator import Paginator
from django.db import migrations


def make_voucher_names_unique(apps, schema_editor):
"""
Appends a number to voucher names.
"""
Voucher = apps.get_model('voucher', 'Voucher')
vouchers = Voucher.objects.order_by('date_created')
paginator = Paginator(vouchers, 1000)

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

for obj in page.object_list:
if f"{obj.id} -" not in obj.name:
obj.name = '%d - %s' % (obj.id, obj.name)
if len(obj.name) > 128:
obj.name = obj.name[:128]
updates.append(obj)

Voucher.objects.bulk_update(updates, ['name'])


class Migration(migrations.Migration):

dependencies = [
('voucher', '0012_voucher_is_public'),
]

operations = [
migrations.RunPython(make_voucher_names_unique, migrations.RunPython.noop),
]
Loading