feat: TNL-10136 fix lint errors
And import cross-references And wrap-around lines
This commit is contained in:
@@ -11,8 +11,8 @@ from django.conf import settings
|
|||||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
|
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
|
||||||
from django.core.validators import FileExtensionValidator, RegexValidator
|
from django.core.validators import FileExtensionValidator
|
||||||
from django.db import IntegrityError, models
|
from django.db import models
|
||||||
from django.db.models import Count, Index, Q
|
from django.db.models import Count, Index, Q
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
@@ -20,7 +20,7 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
from edx_django_utils.cache import RequestCache, TieredCache, get_cache_key
|
from edx_django_utils.cache import RequestCache, TieredCache, get_cache_key
|
||||||
from eventtracking import tracker
|
from eventtracking import tracker
|
||||||
from model_utils.models import TimeStampedModel
|
from model_utils.models import TimeStampedModel
|
||||||
from opaque_keys.edx.django.models import CourseKeyField, LearningContextKeyField
|
from opaque_keys.edx.django.models import CourseKeyField
|
||||||
from opaque_keys.edx.keys import CourseKey
|
from opaque_keys.edx.keys import CourseKey
|
||||||
from openedx_events.learning.data import CourseData, CourseEnrollmentData, UserData, UserPersonalData
|
from openedx_events.learning.data import CourseData, CourseEnrollmentData, UserData, UserPersonalData
|
||||||
from openedx_events.learning.signals import (
|
from openedx_events.learning.signals import (
|
||||||
@@ -29,7 +29,7 @@ from openedx_events.learning.signals import (
|
|||||||
COURSE_UNENROLLMENT_COMPLETED,
|
COURSE_UNENROLLMENT_COMPLETED,
|
||||||
)
|
)
|
||||||
from openedx_filters.learning.filters import CourseEnrollmentStarted, CourseUnenrollmentStarted
|
from openedx_filters.learning.filters import CourseEnrollmentStarted, CourseUnenrollmentStarted
|
||||||
from pytz import UTC, timezone
|
from pytz import UTC
|
||||||
from requests.exceptions import HTTPError, RequestException
|
from requests.exceptions import HTTPError, RequestException
|
||||||
from simple_history.models import HistoricalRecords
|
from simple_history.models import HistoricalRecords
|
||||||
|
|
||||||
@@ -61,6 +61,7 @@ log = logging.getLogger(__name__)
|
|||||||
AUDIT_LOG = logging.getLogger("audit")
|
AUDIT_LOG = logging.getLogger("audit")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ENROLL signal used for free enrollment only
|
# ENROLL signal used for free enrollment only
|
||||||
class EnrollStatusChange:
|
class EnrollStatusChange:
|
||||||
"""
|
"""
|
||||||
@@ -607,6 +608,7 @@ class CourseEnrollment(models.Model):
|
|||||||
segment_properties['course_start'] = self.course.start
|
segment_properties['course_start'] = self.course.start
|
||||||
segment_properties['course_pacing'] = self.course.pacing
|
segment_properties['course_pacing'] = self.course.pacing
|
||||||
|
|
||||||
|
from .user import is_personalized_recommendation_for_user
|
||||||
course_key = f'{self.course_id.org}+{self.course_id.course}'
|
course_key = f'{self.course_id.org}+{self.course_id.course}'
|
||||||
is_personalized_recommendation = is_personalized_recommendation_for_user(course_key)
|
is_personalized_recommendation = is_personalized_recommendation_for_user(course_key)
|
||||||
if is_personalized_recommendation is not None:
|
if is_personalized_recommendation is not None:
|
||||||
|
|||||||
@@ -15,12 +15,20 @@ import hashlib # lint-amnesty, pylint: disable=wrong-import-order
|
|||||||
import json # lint-amnesty, pylint: disable=wrong-import-order
|
import json # lint-amnesty, pylint: disable=wrong-import-order
|
||||||
import logging # lint-amnesty, pylint: disable=wrong-import-order
|
import logging # lint-amnesty, pylint: disable=wrong-import-order
|
||||||
import uuid # lint-amnesty, pylint: disable=wrong-import-order
|
import uuid # lint-amnesty, pylint: disable=wrong-import-order
|
||||||
from datetime import date, datetime, timedelta # lint-amnesty, pylint: disable=wrong-import-order
|
from datetime import datetime, timedelta # lint-amnesty, pylint: disable=wrong-import-order
|
||||||
from functools import total_ordering # lint-amnesty, pylint: disable=wrong-import-order
|
from functools import total_ordering # lint-amnesty, pylint: disable=wrong-import-order
|
||||||
from importlib import import_module # lint-amnesty, pylint: disable=wrong-import-order
|
from importlib import import_module # lint-amnesty, pylint: disable=wrong-import-order
|
||||||
from urllib.parse import unquote, urlencode, urljoin
|
from urllib.parse import unquote, urlencode
|
||||||
|
|
||||||
import crum
|
import crum
|
||||||
|
|
||||||
|
from .course_enrollment import (
|
||||||
|
ALLOWEDTOENROLL_TO_ENROLLED,
|
||||||
|
CourseEnrollment,
|
||||||
|
CourseEnrollmentAllowed,
|
||||||
|
ManualEnrollmentAudit
|
||||||
|
)
|
||||||
|
|
||||||
from config_models.models import ConfigurationModel
|
from config_models.models import ConfigurationModel
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -28,10 +36,10 @@ from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imp
|
|||||||
from django.contrib.auth.signals import user_logged_in, user_logged_out
|
from django.contrib.auth.signals import user_logged_in, user_logged_out
|
||||||
from django.contrib.sites.models import Site
|
from django.contrib.sites.models import Site
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.core.validators import FileExtensionValidator, RegexValidator
|
from django.core.validators import FileExtensionValidator, RegexValidator
|
||||||
from django.db import IntegrityError, models
|
from django.db import IntegrityError, models
|
||||||
from django.db.models import Count, Index, Q
|
from django.db.models import Q
|
||||||
from django.db.models.signals import post_save, pre_save
|
from django.db.models.signals import post_save, pre_save
|
||||||
from django.db.utils import ProgrammingError
|
from django.db.utils import ProgrammingError
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
@@ -39,14 +47,14 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
from django.utils.translation import gettext_noop
|
from django.utils.translation import gettext_noop
|
||||||
from django_countries.fields import CountryField
|
from django_countries.fields import CountryField
|
||||||
from edx_django_utils import monitoring
|
from edx_django_utils import monitoring
|
||||||
from edx_django_utils.cache import RequestCache, TieredCache, get_cache_key
|
from edx_django_utils.cache import RequestCache
|
||||||
from model_utils.models import TimeStampedModel
|
from model_utils.models import TimeStampedModel
|
||||||
from opaque_keys.edx.django.models import CourseKeyField, LearningContextKeyField
|
from opaque_keys.edx.django.models import CourseKeyField, LearningContextKeyField
|
||||||
from pytz import UTC, timezone
|
from pytz import UTC, timezone
|
||||||
from user_util import user_util
|
from user_util import user_util
|
||||||
|
|
||||||
import openedx.core.djangoapps.django_comment_common.comment_client as cc
|
import openedx.core.djangoapps.django_comment_common.comment_client as cc
|
||||||
from common.djangoapps.track import contexts, segment
|
from common.djangoapps.track import segment
|
||||||
from common.djangoapps.util.model_utils import emit_field_changed_events, get_changed_fields_dict
|
from common.djangoapps.util.model_utils import emit_field_changed_events, get_changed_fields_dict
|
||||||
from lms.djangoapps.courseware.toggles import streak_celebration_is_active
|
from lms.djangoapps.courseware.toggles import streak_celebration_is_active
|
||||||
from openedx.core.djangoapps.signals.signals import USER_ACCOUNT_ACTIVATED
|
from openedx.core.djangoapps.signals.signals import USER_ACCOUNT_ACTIVATED
|
||||||
@@ -1045,8 +1053,6 @@ class LoginFailures(models.Model):
|
|||||||
verbose_name_plural = 'Login Failures'
|
verbose_name_plural = 'Login Failures'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@total_ordering
|
@total_ordering
|
||||||
class CourseAccessRole(models.Model):
|
class CourseAccessRole(models.Model):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -156,7 +156,8 @@ class TestStudentDashboardUnenrollments(SharedModuleStoreTestCase):
|
|||||||
assert json.loads(response.content.decode('utf-8')) == {'course_refundable_status': True}
|
assert json.loads(response.content.decode('utf-8')) == {'course_refundable_status': True}
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
with patch('common.djangoapps.student.models.course_enrollment.CourseEnrollment.refundable', return_value=False):
|
REFUNDABLE_METHOD_NAME = 'common.djangoapps.student.models.course_enrollment.CourseEnrollment.refundable'
|
||||||
|
with patch(REFUNDABLE_METHOD_NAME, return_value=False):
|
||||||
response = self.client.get(reverse('course_run_refund_status', kwargs={'course_id': self.course.id}))
|
response = self.client.get(reverse('course_run_refund_status', kwargs={'course_id': self.course.id}))
|
||||||
|
|
||||||
assert json.loads(response.content.decode('utf-8')) == {'course_refundable_status': False}
|
assert json.loads(response.content.decode('utf-8')) == {'course_refundable_status': False}
|
||||||
|
|||||||
@@ -761,7 +761,8 @@ class DiscussionLinkTestCase(TabTestCase):
|
|||||||
is_enrolled=True
|
is_enrolled=True
|
||||||
):
|
):
|
||||||
"""Helper function to verify whether the discussion tab exists and can be displayed"""
|
"""Helper function to verify whether the discussion tab exists and can be displayed"""
|
||||||
with patch('common.djangoapps.student.models.course_enrollment.CourseEnrollment.is_enrolled') as check_is_enrolled:
|
IS_ENROLLED_METHOD_NAME = 'common.djangoapps.student.models.course_enrollment.CourseEnrollment.is_enrolled'
|
||||||
|
with patch(IS_ENROLLED_METHOD_NAME) as check_is_enrolled:
|
||||||
self.course.tabs = tab_list
|
self.course.tabs = tab_list
|
||||||
self.course.discussion_link = discussion_link_in_course
|
self.course.discussion_link = discussion_link_in_course
|
||||||
discussion_tab = xmodule_tabs.CourseTabList.get_discussion(self.course)
|
discussion_tab = xmodule_tabs.CourseTabList.get_discussion(self.course)
|
||||||
|
|||||||
Reference in New Issue
Block a user