Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
dd53edc6
Commit
dd53edc6
authored
7 years ago
by
Calen Pennington
Committed by
sandroroux
7 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache upgrade_deadline on CourseEnrollment objects
parent
f8d41b97
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletions
+16
-1
common/djangoapps/student/models.py
+1
-1
common/djangoapps/student/tests/test_models.py
+15
-0
No files found.
common/djangoapps/student/models.py
View file @
dd53edc6
...
@@ -1696,7 +1696,7 @@ class CourseEnrollment(models.Model):
...
@@ -1696,7 +1696,7 @@ class CourseEnrollment(models.Model):
def
verified_mode
(
self
):
def
verified_mode
(
self
):
return
CourseMode
.
verified_mode_for_course
(
self
.
course_id
)
return
CourseMode
.
verified_mode_for_course
(
self
.
course_id
)
@property
@
cached_
property
def
upgrade_deadline
(
self
):
def
upgrade_deadline
(
self
):
"""
"""
Returns the upgrade deadline for this enrollment, if it is upgradeable.
Returns the upgrade deadline for this enrollment, if it is upgradeable.
...
...
This diff is collapsed.
Click to expand it.
common/djangoapps/student/tests/test_models.py
View file @
dd53edc6
...
@@ -132,6 +132,21 @@ class CourseEnrollmentTests(SharedModuleStoreTestCase):
...
@@ -132,6 +132,21 @@ class CourseEnrollmentTests(SharedModuleStoreTestCase):
self
.
assertEqual
(
Schedule
.
objects
.
all
()
.
count
(),
0
)
self
.
assertEqual
(
Schedule
.
objects
.
all
()
.
count
(),
0
)
self
.
assertEqual
(
enrollment
.
upgrade_deadline
,
course_mode
.
expiration_datetime
)
self
.
assertEqual
(
enrollment
.
upgrade_deadline
,
course_mode
.
expiration_datetime
)
@skip_unless_lms
# NOTE: We mute the post_save signal to prevent Schedules from being created for new enrollments
@factory.django.mute_signals
(
signals
.
post_save
)
def
test_upgrade_deadline_with_schedule
(
self
):
""" The property should use either the CourseMode or related Schedule to determine the deadline. """
course
=
CourseFactory
(
self_paced
=
True
)
CourseModeFactory
(
course_id
=
course
.
id
,
mode_slug
=
CourseMode
.
VERIFIED
,
# This must be in the future to ensure it is returned by downstream code.
expiration_datetime
=
datetime
.
datetime
.
now
(
pytz
.
UTC
)
+
datetime
.
timedelta
(
days
=
1
),
)
enrollment
=
CourseEnrollmentFactory
(
course_id
=
course
.
id
,
mode
=
CourseMode
.
AUDIT
)
# The schedule's upgrade deadline should be used if a schedule exists
# The schedule's upgrade deadline should be used if a schedule exists
DynamicUpgradeDeadlineConfiguration
.
objects
.
create
(
enabled
=
True
)
DynamicUpgradeDeadlineConfiguration
.
objects
.
create
(
enabled
=
True
)
schedule
=
ScheduleFactory
(
enrollment
=
enrollment
)
schedule
=
ScheduleFactory
(
enrollment
=
enrollment
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment