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

Refactoring code for Django 4.2 #4073

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

on:
push:
branches: [master]
branches: ['*']
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this change intentional? If yes, we can instead use only the headers to achieve the same purpose so following will work as well for all branches

on: 
    push:
    pull_request:

pull_request:
branches: [master]
branches: ['*']

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/migrations-mysql8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:
push:
branches:
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly this can also be changed to only following:

on: 
   push:

- master
- '*'

jobs:
check_migrations:
Expand Down
1 change: 0 additions & 1 deletion ecommerce/bff/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = 'ecommerce.bff.config.BffConfig' # pragma: no cover
14 changes: 7 additions & 7 deletions ecommerce/bff/payment/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


from django.conf.urls import include, url
from django.urls import include, path, re_path
from rest_framework.urlpatterns import format_suffix_patterns

from ecommerce.extensions.basket.views import (
Expand All @@ -12,15 +12,15 @@
)

PAYMENT_URLS = [
url(r'^capture-context/$', CaptureContextApiView.as_view(), name='capture_context'),
url(r'^payment/$', PaymentApiView.as_view(), name='payment'),
url(r'^quantity/$', QuantityAPIView.as_view(), name='quantity'),
url(r'^vouchers/$', VoucherAddApiView.as_view(), name='addvoucher'),
url(r'^vouchers/(?P<voucherid>[\d]+)$', VoucherRemoveApiView.as_view(), name='removevoucher'),
path('capture-context/', CaptureContextApiView.as_view(), name='capture_context'),
path('payment/', PaymentApiView.as_view(), name='payment'),
path('quantity/', QuantityAPIView.as_view(), name='quantity'),
path('vouchers/', VoucherAddApiView.as_view(), name='addvoucher'),
re_path(r'^vouchers/(?P<voucherid>[\d]+)$', VoucherRemoveApiView.as_view(), name='removevoucher'),
]

urlpatterns = [
url(r'^v0/', include((PAYMENT_URLS, 'v0'))),
path('v0/', include((PAYMENT_URLS, 'v0'))),
]

urlpatterns = format_suffix_patterns(urlpatterns)
6 changes: 3 additions & 3 deletions ecommerce/bff/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@


from django.conf.urls import include, url
from django.urls import include, path

urlpatterns = [
url(r'^payment/', include(('ecommerce.bff.payment.urls', 'payment'))),
url(r'subscriptions/', include(('ecommerce.bff.subscriptions.urls', 'subscriptions')))
path('payment/', include(('ecommerce.bff.payment.urls', 'payment'))),
path('subscriptions/', include(('ecommerce.bff.subscriptions.urls', 'subscriptions')))

]
1 change: 0 additions & 1 deletion ecommerce/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = 'ecommerce.core.config.CoreAppConfig' # pragma: no cover
2 changes: 1 addition & 1 deletion ecommerce/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import waffle
from django.contrib import admin, messages
from django.contrib.auth.admin import UserAdmin
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from edx_rbac.admin import UserRoleAssignmentAdmin

from ecommerce.core.constants import USER_LIST_VIEW_SWITCH
Expand Down
2 changes: 1 addition & 1 deletion ecommerce/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.core.exceptions import ValidationError
from django.db import models
from django.utils.functional import cached_property
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from edx_django_utils import monitoring as monitoring_utils
from edx_rbac.models import UserRole, UserRoleAssignment
from edx_rest_api_client.client import OAuthAPIClient
Expand Down
10 changes: 5 additions & 5 deletions ecommerce/coupons/urls.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@


from django.conf.urls import url
from django.urls import path, re_path

from ecommerce.coupons import views

urlpatterns = [
url(r'^offer/$', views.CouponOfferView.as_view(), name='offer'),
url(r'^redeem/$', views.CouponRedeemView.as_view(), name='redeem'),
url(
path('offer/', views.CouponOfferView.as_view(), name='offer'),
path('redeem/', views.CouponRedeemView.as_view(), name='redeem'),
re_path(
r'^enrollment_code_csv/(?P<number>[-\w]+)/$',
views.EnrollmentCodeCsvView.as_view(),
name='enrollment_code_csv'
),
url(r'^(.*)$', views.CouponAppView.as_view(), name='app'),
re_path(r'^(.*)$', views.CouponAppView.as_view(), name='app'),
]
2 changes: 1 addition & 1 deletion ecommerce/coupons/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.utils.text import slugify
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.generic import TemplateView, View
from edx_rest_framework_extensions.permissions import LoginRedirectIfUnauthenticated
from oscar.core.loading import get_class, get_model
Expand Down
4 changes: 1 addition & 3 deletions ecommerce/courses/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
from ecommerce.courses.models import Course


@admin.register(Course)
class CourseAdmin(admin.ModelAdmin):
list_display = ('id', 'name', 'partner',)
search_fields = ('id', 'name', 'partner', )
list_filter = ('partner', )


admin.site.register(Course, CourseAdmin)
2 changes: 1 addition & 1 deletion ecommerce/courses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.db import models, transaction
from django.db.models import Count, Q
from django.utils.timezone import now, timedelta
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from oscar.core.loading import get_class, get_model
from simple_history.models import HistoricalRecords

Expand Down
2 changes: 1 addition & 1 deletion ecommerce/courses/publishers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from urllib.parse import urljoin

from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from oscar.core.loading import get_model
from requests.exceptions import HTTPError

Expand Down
8 changes: 4 additions & 4 deletions ecommerce/courses/urls.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@


from django.conf.urls import url
from django.urls import path, re_path

from ecommerce.courses import views

urlpatterns = [
url(r'^migrate/$', views.CourseMigrationView.as_view(), name='migrate'),
url(r'^convert_course/$', views.ConvertCourseView.as_view(), name='convert_course'),
path('migrate/', views.CourseMigrationView.as_view(), name='migrate'),
path('convert_course/', views.ConvertCourseView.as_view(), name='convert_course'),

# Declare all paths above this line to avoid dropping into the Course Admin Tool (which does its own routing)
url(r'^(.*)$', views.CourseAppView.as_view(), name='app'),
re_path(r'^(.*)$', views.CourseAppView.as_view(), name='app'),
]
2 changes: 1 addition & 1 deletion ecommerce/courses/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from urllib.parse import urljoin

from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from edx_django_utils.cache import TieredCache
from opaque_keys.edx.keys import CourseKey

Expand Down
5 changes: 2 additions & 3 deletions ecommerce/credit/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@


from django.conf.urls import url
from django.urls import re_path

from ecommerce.core.constants import COURSE_ID_PATTERN
from ecommerce.credit.views import Checkout

urlpatterns = [
url(r'^checkout/{course}/$'.format(course=COURSE_ID_PATTERN),
Checkout.as_view(), name='checkout'),
re_path(r'^checkout/{course}/$'.format(course=COURSE_ID_PATTERN), Checkout.as_view(), name='checkout'),
]
2 changes: 1 addition & 1 deletion ecommerce/credit/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView
from oscar.core.loading import get_model
from requests.exceptions import HTTPError
Expand Down
2 changes: 1 addition & 1 deletion ecommerce/enterprise/benefits.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from oscar.core.loading import get_model

from ecommerce.extensions.offer.mixins import AbsoluteBenefitMixin, BenefitWithoutRangeMixin, PercentageBenefitMixin
Expand Down
2 changes: 1 addition & 1 deletion ecommerce/enterprise/conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import crum
from django.contrib import messages
from django.db.models import Sum
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from oscar.core.loading import get_model
from requests.exceptions import ConnectionError as ReqConnectionError
from requests.exceptions import HTTPError, Timeout
Expand Down
2 changes: 1 addition & 1 deletion ecommerce/enterprise/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.core.validators import validate_email
from django.db.models import Count, Max, Sum
from django.forms.utils import ErrorList
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from oscar.core.loading import get_model

from ecommerce.enterprise.benefits import BENEFIT_MAP, BENEFIT_TYPE_CHOICES
Expand Down
12 changes: 6 additions & 6 deletions ecommerce/enterprise/urls.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@


from django.conf.urls import include, url
from django.urls import include, path, re_path

from ecommerce.enterprise import views

OFFER_URLS = [
url(r'^$', views.EnterpriseOfferListView.as_view(), name='list'),
url(r'^new/$', views.EnterpriseOfferCreateView.as_view(), name='new'),
url(r'^(?P<pk>[\d]+)/edit/$', views.EnterpriseOfferUpdateView.as_view(), name='edit'),
path('', views.EnterpriseOfferListView.as_view(), name='list'),
path('new/', views.EnterpriseOfferCreateView.as_view(), name='new'),
re_path(r'^(?P<pk>[\d]+)/edit/$', views.EnterpriseOfferUpdateView.as_view(), name='edit'),
]

urlpatterns = [
url(r'^offers/', include((OFFER_URLS, 'offers'))),
url(r'^coupons/(.*)$', views.EnterpriseCouponAppView.as_view(), name='coupons'),
path('offers/', include((OFFER_URLS, 'offers'))),
re_path(r'^coupons/(.*)$', views.EnterpriseCouponAppView.as_view(), name='coupons'),
]
2 changes: 1 addition & 1 deletion ecommerce/enterprise/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import crum
from django.conf import settings
from django.urls import reverse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from edx_django_utils.cache import TieredCache
from edx_rest_framework_extensions.auth.jwt.cookies import get_decoded_jwt
from oscar.core.loading import get_model
Expand Down
2 changes: 1 addition & 1 deletion ecommerce/enterprise/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from django.contrib import messages
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.views.generic import CreateView, ListView, TemplateView, UpdateView
from oscar.core.loading import get_model

Expand Down
1 change: 0 additions & 1 deletion ecommerce/extensions/analytics/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = 'ecommerce.extensions.analytics.apps.AnalyticsConfig' # pragma: no cover
2 changes: 1 addition & 1 deletion ecommerce/extensions/analytics/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ def process_view(self, request, view_func, view_args, view_kwargs): # pylint: d
# If the user does not already have an LMS user id, add it
called_from = u'middleware with request path: {request}, referrer: {referrer}'.format(
request=request.get_full_path(),
referrer=request.META.get('HTTP_REFERER'))
referrer=request.headers.get('referer'))
Copy link
Contributor

Choose a reason for hiding this comment

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

We can skip this change for now as both are supported with Django 42

user.add_lms_user_id('ecommerce_missing_lms_user_id_middleware', called_from)
2 changes: 1 addition & 1 deletion ecommerce/extensions/api/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Exceptions and error messages used by the ecommerce API."""


from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from rest_framework import status
from rest_framework.exceptions import APIException

Expand Down
2 changes: 1 addition & 1 deletion ecommerce/extensions/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from django.db import transaction
from django.db.models import Count, Q, Sum, prefetch_related_objects
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from opaque_keys.edx.keys import CourseKey
from oscar.core.loading import get_class, get_model
from rest_framework import serializers
Expand Down
4 changes: 2 additions & 2 deletions ecommerce/extensions/api/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


from django.conf.urls import include, url
from django.urls import include, path

urlpatterns = [
url(r'^v2/', include(('ecommerce.extensions.api.v2.urls', 'v2'))),
path('v2/', include(('ecommerce.extensions.api.v2.urls', 'v2'))),
]
Loading
Loading