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
9c2530ce
Commit
9c2530ce
authored
Dec 20, 2017
by
Jeff LaJoie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LEARNER-3638: Fixes expiration issues for learners who upgrade late into a course
parent
72bb440d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletions
+18
-1
common/djangoapps/entitlements/models.py
+2
-1
common/djangoapps/entitlements/tests/test_models.py
+16
-0
No files found.
common/djangoapps/entitlements/models.py
View file @
9c2530ce
...
...
@@ -54,10 +54,11 @@ class CourseEntitlementPolicy(models.Model):
# Compute the days left for the regain
days_since_course_start
=
(
now
-
course_overview
.
start
)
.
days
days_since_enrollment
=
(
now
-
entitlement
.
enrollment_course_run
.
created
)
.
days
days_since_entitlement_created
=
(
now
-
entitlement
.
created
)
.
days
# We want to return whichever days value is less since it is then the more recent one
days_until_regain_ends
=
(
self
.
regain_period
.
days
-
# pylint: disable=no-member
min
(
days_since_course_start
,
days_since_enrollment
))
min
(
days_since_course_start
,
days_since_enrollment
,
days_since_entitlement_created
))
# If the base days until expiration is less than the days until the regain period ends, use that instead
if
days_until_expiry
<
days_until_regain_ends
:
...
...
common/djangoapps/entitlements/tests/test_models.py
View file @
9c2530ce
...
...
@@ -168,6 +168,7 @@ class TestModels(TestCase):
self
.
enrollment
.
created
=
past_datetime
self
.
course
.
start
=
past_datetime
entitlement
.
save
()
entitlement
.
refresh_from_db
()
self
.
course
.
save
()
self
.
enrollment
.
save
()
assert
entitlement
.
enrollment_course_run
...
...
@@ -175,6 +176,21 @@ class TestModels(TestCase):
assert
expired_at_datetime
assert
entitlement
.
expired_at
# Verify that an entitlement that has just been created, but the user has been enrolled in the course for
# greater than 14 days, and the course started more than 14 days ago is not expired
entitlement
=
CourseEntitlementFactory
.
create
(
enrollment_course_run
=
self
.
enrollment
)
past_datetime
=
datetime
.
utcnow
()
.
replace
(
tzinfo
=
pytz
.
UTC
)
-
timedelta
(
days
=
20
)
entitlement
.
created
=
datetime
.
utcnow
()
.
replace
(
tzinfo
=
pytz
.
UTC
)
self
.
enrollment
.
created
=
past_datetime
self
.
course
.
start
=
past_datetime
entitlement
.
save
()
self
.
enrollment
.
save
()
self
.
course
.
save
()
assert
entitlement
.
enrollment_course_run
expired_at_datetime
=
entitlement
.
expired_at_datetime
assert
expired_at_datetime
is
None
assert
entitlement
.
expired_at
is
None
# Verify a date 451 days in the past (1 days after the policy expiration)
# That is enrolled and started in within the regain period is still expired
entitlement
=
CourseEntitlementFactory
.
create
(
enrollment_course_run
=
self
.
enrollment
)
...
...
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