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

Commit

Permalink
Backport Django 3.2 upgrade in maple release (#3577)
Browse files Browse the repository at this point in the history
* chore: remove pytest-django-ordering (#3515)

* feat: implement create_from_breadcrumbs locally to remove blocker for django-oscar 2.1 upgrade

* feat: implement create_from_breadcrumbs locally to avoid management command

* test: adding test for create_subcategories method

* fix: isort test_utils.py

* fix: add test for line that returns early

Co-authored-by: Diane Kaplan <[email protected]>

* Revert "Revert "build: upgrade crispy forms" (#3550)"

This reverts commit efd105b.

* Revert "Revert "build: upgrade pytest & pytest-django""

This reverts commit 87d7d4e.

* chore: remove karma-jquery plugin from karma and link to jquery directly, to enable upgrades to jquery 3.5 and django-oscar 2.1 (#3565)

* fix: remove karma-jquery and use jquery 3.2.1 directly

* fix: remove jquery from karma frameworks

Co-authored-by: Diane Kaplan <[email protected]>

* build(deps): bump jquery from 3.2.1 to 3.5.0 (#3566)

Bumps [jquery](https://github.com/jquery/jquery) from 3.2.1 to 3.5.0.
- [Release notes](https://github.com/jquery/jquery/releases)
- [Commits](jquery/jquery@3.2.1...3.5.0)

---
updated-dependencies:
- dependency-name: jquery
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: upgrade oscar-django 2.1 with dependent packages (needed to get to django 3.2)

* feat: upgrade Django version to 3.2

* test: In django32 delete with distinct is not working.

Applied the alternate solution.

* chore: ran django codemods

* fix: modify custom user model to avoid large migration on user_auth table

* chore: add final django-oscar upgrade migration (#3597)

Co-authored-by: Max Sokolski <[email protected]>
Co-authored-by: Diane Kaplan <[email protected]>
Co-authored-by: Usama Sadiq <[email protected]>
Co-authored-by: Diane Kaplan <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Awais Qureshi <[email protected]>
Co-authored-by: M. Zulqarnain <[email protected]>
  • Loading branch information
8 people authored Dec 17, 2021
1 parent 90a994d commit 2be41ee
Show file tree
Hide file tree
Showing 72 changed files with 930 additions and 337 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ jobs:
strategy:
matrix:
include:
- django-env: django22
- django-env: django32
testname: quality-and-jobs
targets: PYTHON_ENV=py38 requirements.js check_translations_up_to_date validate_translations clean_static static quality validate_js check_keywords
- django-env: django22
- django-env: django32
testname: test-python
targets: PYTHON_ENV=py38 requirements.js clean_static static validate_python
- django-env: django22
- django-env: django32
testname: acceptance-python
targets: PYTHON_ENV=py38 requirements.js clean_static static acceptance

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NODE_BIN=./node_modules/.bin
DIFF_COVER_BASE_BRANCH=master
PYTHON_ENV=py38
DJANGO_ENV_VAR=$(if $(DJANGO_ENV),$(DJANGO_ENV),django22)
DJANGO_ENV_VAR=$(if $(DJANGO_ENV),$(DJANGO_ENV),django32)

help:
@echo ''
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"datatables": "1.10.10",
"edx-ux-pattern-library": "https://github.com/edx/ux-pattern-library.git#82fa1c823bc322ba8b0742f0c546a89b0c69e952",
"fontawesome": "~4.3.0",
"jquery": "~3.2.1",
"jquery": "3.5.0",
"js-cookie": "~2.1.2",
"moment": "~2.10.3",
"pikaday": "https://github.com/owenmead/Pikaday.git#1.4.0",
Expand Down
5 changes: 2 additions & 3 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
SEAT_PRODUCT_CLASS_NAME
)
from ecommerce.extensions.basket.constants import EMAIL_OPT_IN_ATTRIBUTE, PURCHASER_BEHALF_ATTRIBUTE
from ecommerce.extensions.catalogue.utils import create_subcategories
from ecommerce.extensions.checkout.signals import BUNDLE
from ecommerce.core.constants import ORDER_MANAGER_ROLE
from ecommerce.core.constants import DONATIONS_FROM_CHECKOUT_TESTS_PRODUCT_TYPE_NAME
from ecommerce.core.constants import ENTERPRISE_COUPON_ADMIN_ROLE
from oscar.apps.catalogue.categories import create_from_breadcrumbs


COUPON_CATEGORY_NAME = 'Coupons'
Expand Down Expand Up @@ -316,6 +316,5 @@ def django_db_setup(django_db_setup, django_db_blocker, django_db_use_migrations

EcommerceFeatureRole.objects.get_or_create(name=ENTERPRISE_COUPON_ADMIN_ROLE)

for category in DEFAULT_CATEGORIES:
create_from_breadcrumbs('{} > {}'.format(COUPON_CATEGORY_NAME, category))
create_subcategories(Category, COUPON_CATEGORY_NAME, DEFAULT_CATEGORIES)

2 changes: 1 addition & 1 deletion docs/additional_features/send_notifications.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Create an Email Message

The E-Commerce service can send both HTML and plain text email messages. To
create an email message, create the following three files in the
``ecommerce/ecommerce/templates/customer/emails/`` folder.
``ecommerce/ecommerce/templates/oscar/communication/emails/`` folder.

* An HTML template that extends ``email_base.html`` and includes the body of
the email.
Expand Down
3 changes: 3 additions & 0 deletions ecommerce/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@ class User(AbstractUser):
# on the ecommerce_user table that would otherwise have come with Django 2.
# See https://docs.djangoproject.com/en/3.0/releases/2.0/#abstractuser-last-name-max-length-increased-to-150
last_name = models.CharField(_('last name'), max_length=30, blank=True)
# Similarly, this avoids a large migration which otherwise would come with Django 3.2
# See, https://docs.djangoproject.com/en/3.2/releases/3.1/#abstractuser-first-name-max-length-increased-to-150
first_name = models.CharField(_('first name'), max_length=30, blank=True)
full_name = models.CharField(_('Full Name'), max_length=255, blank=True, null=True)
tracking_context = JSONField(blank=True, null=True)
email = models.EmailField(max_length=254, verbose_name='email address', blank=True, db_index=True)
Expand Down
18 changes: 18 additions & 0 deletions ecommerce/extensions/basket/migrations/0014_line_date_updated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.24 on 2021-09-22 18:57

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('basket', '0013_auto_20200305_1448'),
]

operations = [
migrations.AddField(
model_name='line',
name='date_updated',
field=models.DateTimeField(auto_now=True, db_index=True, verbose_name='Date Updated'),
),
]
2 changes: 0 additions & 2 deletions ecommerce/extensions/basket/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@


from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from edx_django_utils.cache import DEFAULT_REQUEST_CACHE
from oscar.apps.basket.abstract_models import AbstractBasket
Expand All @@ -16,7 +15,6 @@
Selector = get_class('partner.strategy', 'Selector')


@python_2_unicode_compatible
class Basket(AbstractBasket):
site = models.ForeignKey(
'sites.Site', verbose_name=_("Site"), null=True, blank=True, default=None, on_delete=models.SET_NULL
Expand Down
2 changes: 1 addition & 1 deletion ecommerce/extensions/basket/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,7 @@ def test_response_validation_error(self):
expected_messages = [
{
'message_type': 'warning',
'user_message': "Your cart couldn't be updated. Please correct any validation errors below.",
'user_message': "Your basket couldn't be updated. Please correct any validation errors below.",
},
{
'message_type': 'warning',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@


from django.db import migrations
from oscar.core.loading import get_model
from oscar.core.utils import slugify

from ecommerce.core.constants import COUPON_PRODUCT_CLASS_NAME

Category = get_model("catalogue", "Category")
ProductAttribute = get_model("catalogue", "ProductAttribute")
ProductClass = get_model("catalogue", "ProductClass")


def create_product_class(apps, schema_editor):
"""Create a Coupon product class."""
Category = apps.get_model("catalogue", "Category")
ProductAttribute = apps.get_model("catalogue", "ProductAttribute")
ProductClass = apps.get_model("catalogue", "ProductClass")

for klass in (Category, ProductAttribute, ProductClass):
klass.skip_history_when_saving = True

Expand Down Expand Up @@ -48,13 +47,19 @@ def create_product_class(apps, schema_editor):

def remove_product_class(apps, schema_editor):
""" Reverse function. """
Category = apps.get_model("catalogue", "Category")
ProductClass = apps.get_model("catalogue", "ProductClass")

ProductClass.skip_history_when_saving = True
Category.objects.filter(slug='coupon').delete()
ProductClass.objects.filter(name=COUPON_PRODUCT_CLASS_NAME).delete()


def remove_enrollment_code(apps, schema_editor):
""" Removes the enrollment code product and it's attributes. """
Category = apps.get_model("catalogue", "Category")
ProductClass = apps.get_model("catalogue", "ProductClass")

ProductClass.skip_history_when_saving = True
Category.objects.filter(slug='enrollment_codes').delete()
ProductClass.objects.filter(slug='enrollment_code').delete()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@


from django.db import migrations
from oscar.apps.catalogue.categories import create_from_breadcrumbs
from oscar.core.loading import get_model

Category = get_model("catalogue", "Category")
from ecommerce.extensions.catalogue.utils import create_subcategories


COUPON_CATEGORY_NAME = 'Coupons'

Expand All @@ -19,14 +18,16 @@

def create_default_categories(apps, schema_editor):
"""Create default coupon categories."""
Category.skip_history_when_saving = True
Category = apps.get_model("catalogue", "Category")

for category in DEFAULT_CATEGORIES:
create_from_breadcrumbs('{} > {}'.format(COUPON_CATEGORY_NAME, category))
Category.skip_history_when_saving = True
create_subcategories(Category, COUPON_CATEGORY_NAME, DEFAULT_CATEGORIES)


def remove_default_categories(apps, schema_editor):
"""Remove default coupon categories."""
Category = apps.get_model("catalogue", "Category")

Category.skip_history_when_saving = True
Category.objects.get(name=COUPON_CATEGORY_NAME).get_children().filter(
name__in=DEFAULT_CATEGORIES
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
# -*- coding: utf-8 -*-


from django.db import migrations, models
from oscar.core.loading import get_model
from django.db import migrations
from oscar.core.utils import slugify

from ecommerce.core.constants import COURSE_ENTITLEMENT_PRODUCT_CLASS_NAME

Category = get_model("catalogue", "Category")
Product = get_model('catalogue', 'Product')
ProductAttribute = get_model("catalogue", "ProductAttribute")
ProductClass = get_model("catalogue", "ProductClass")


def create_product_class(apps, schema_editor):
""" Create a course entitlement product class """
Category = apps.get_model("catalogue", "Category")
ProductAttribute = apps.get_model("catalogue", "ProductAttribute")
ProductClass = apps.get_model("catalogue", "ProductClass")

for klass in (Category, ProductAttribute, ProductClass):
klass.skip_history_when_saving = True

Expand Down Expand Up @@ -47,16 +45,24 @@ def create_product_class(apps, schema_editor):
pa2.save()

# Create a category for course entitlements
Category.add_root(
c = Category(
description="All course entitlements",
slug="course_entitlements",
image="",
name="Course Entitlements"
name="Course Entitlements",
depth=1,
path='0003',
)
c.save()


def remove_product_class(apps, schema_editor):
""" Reverse function. """
Category = apps.get_model("catalogue", "Category")
Product = apps.get_model('catalogue', 'Product')
ProductAttribute = apps.get_model("catalogue", "ProductAttribute")
ProductClass = apps.get_model("catalogue", "ProductClass")

# ProductAttribute is needed for cascading delete
for klass in (Product, Category, ProductAttribute, ProductClass):
klass.skip_history_when_saving = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@


from django.db import migrations
from oscar.core.loading import get_model
from oscar.core.utils import slugify

from ecommerce.core.constants import DONATIONS_FROM_CHECKOUT_TESTS_PRODUCT_TYPE_NAME

Category = get_model("catalogue", "Category")
Product = get_model('catalogue', 'Product')
ProductAttribute = get_model("catalogue", "ProductAttribute")
ProductClass = get_model("catalogue", "ProductClass")


def create_product_class(apps, schema_editor): # pylint: disable=unused-argument
""" Create a donation product class for donations from checkout tests """
Category = apps.get_model("catalogue", "Category")
ProductClass = apps.get_model("catalogue", "ProductClass")

ProductClass.skip_history_when_saving = True
Category.skip_history_when_saving = True
Expand All @@ -27,16 +23,24 @@ def create_product_class(apps, schema_editor): # pylint: disable=unused-argumen
slug=slugify(DONATIONS_FROM_CHECKOUT_TESTS_PRODUCT_TYPE_NAME)
)

Category.add_root(
# Create a category for donations.
c = Category(
description="All donations",
slug="donations",
image="",
name="Donations"
name="Donations",
depth=1,
path='0004',
)
c.save()


def remove_product_class(apps, schema_editor): # pylint: disable=unused-argument
""" Reverse function. """
Category = apps.get_model("catalogue", "Category")
Product = apps.get_model('catalogue', 'Product')
ProductClass = apps.get_model("catalogue", "ProductClass")

ProductClass.skip_history_when_saving = True
Product.skip_history_when_saving = True
Category.skip_history_when_saving = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@


from django.db import migrations
from oscar.core.loading import get_model
from oscar.core.utils import slugify

JOURNAL_PRODUCT_CLASS_NAME = 'Journal'
Category = get_model("catalogue", "Category")
Product = get_model('catalogue', 'Product')
ProductAttribute = get_model("catalogue", "ProductAttribute")
ProductClass = get_model("catalogue", "ProductClass")
JOURNAL_SLUG_NAME = slugify(JOURNAL_PRODUCT_CLASS_NAME)


def create_product_class(apps, schema_editor):
""" Create a journal product class """
Category = apps.get_model("catalogue", "Category")
Product = apps.get_model('catalogue', 'Product')
ProductAttribute = apps.get_model("catalogue", "ProductAttribute")
ProductClass = apps.get_model("catalogue", "ProductClass")

for klass in (Category, Product, ProductClass, ProductAttribute):
klass.skip_history_when_saving = True

Expand All @@ -38,16 +38,24 @@ def create_product_class(apps, schema_editor):
pa1.save()

# Create a category for the journal
Category.add_root(
c = Category(
description="All journals",
slug="journals",
image="",
name="Journals"
name="Journals",
depth=1,
path='0005',
)
c.save()


def remove_product_class(apps, schema_editor):
""" Reverse function. """
Category = apps.get_model("catalogue", "Category")
Product = apps.get_model('catalogue', 'Product')
ProductAttribute = apps.get_model("catalogue", "ProductAttribute")
ProductClass = apps.get_model("catalogue", "ProductClass")

# ProductAttribute is required here for the cascading delete
for klass in (Category, Product, ProductClass, ProductAttribute):
klass.skip_history_when_saving = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@


from django.db import migrations
from oscar.apps.catalogue.categories import create_from_breadcrumbs
from oscar.core.loading import get_model

Category = get_model('catalogue', 'Category')
from ecommerce.extensions.catalogue.utils import create_subcategories

COUPON_CATEGORY_NAME = 'Coupons'

Expand All @@ -18,14 +16,16 @@

def create_default_categories(apps, schema_editor):
"""Create default coupon categories."""
Category.skip_history_when_saving = True
Category = apps.get_model("catalogue", "Category")

for category in DEFAULT_CATEGORIES:
create_from_breadcrumbs('{} > {}'.format(COUPON_CATEGORY_NAME, category))
Category.skip_history_when_saving = True
create_subcategories(Category, COUPON_CATEGORY_NAME, DEFAULT_CATEGORIES)


def remove_default_categories(apps, schema_editor):
"""Remove default coupon categories."""
Category = apps.get_model("catalogue", "Category")

Category.skip_history_when_saving = True
Category.objects.get(name=COUPON_CATEGORY_NAME).get_children().filter(
name__in=DEFAULT_CATEGORIES
Expand Down
Loading

0 comments on commit 2be41ee

Please sign in to comment.