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
3fbb1571
Commit
3fbb1571
authored
Dec 15, 2017
by
Albert St. Aubin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update to policy check utilities for Course Entitlements
parent
31e8b679
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletions
+21
-1
common/djangoapps/entitlements/models.py
+9
-1
common/djangoapps/entitlements/tests/test_models.py
+12
-0
No files found.
common/djangoapps/entitlements/models.py
View file @
3fbb1571
...
...
@@ -70,6 +70,9 @@ class CourseEntitlementPolicy(models.Model):
to by leaving and regaining their entitlement within policy.regain_period days from start date of
the course or their redemption, whichever comes later, and the expiration period hasn't passed yet
"""
if
entitlement
.
expired_at
:
return
False
if
entitlement
.
enrollment_course_run
:
if
GeneratedCertificate
.
certificate_for_student
(
entitlement
.
user_id
,
entitlement
.
enrollment_course_run
.
course_id
)
is
not
None
:
...
...
@@ -86,6 +89,10 @@ class CourseEntitlementPolicy(models.Model):
yet been redeemed (enrollment_course_run is NULL) and policy.refund_period has not yet passed, or if
the entitlement has been redeemed, but the regain period hasn't passed yet.
"""
# If the Entitlement is expired already it is not refundable
if
entitlement
.
expired_at
:
return
False
# If there's no order number, it cannot be refunded
if
entitlement
.
order_number
is
None
:
return
False
...
...
@@ -108,7 +115,8 @@ class CourseEntitlementPolicy(models.Model):
# This is < because a get_days_since_created of expiration_period means that that many days have passed,
# which should then expire the entitlement
return
(
entitlement
.
get_days_since_created
()
<
self
.
expiration_period
.
days
# pylint: disable=no-member
and
not
entitlement
.
enrollment_course_run
)
and
not
entitlement
.
enrollment_course_run
and
not
entitlement
.
expired_at
)
def
__unicode__
(
self
):
return
u'Course Entitlement Policy: expiration_period: {}, refund_period: {}, regain_period: {}'
\
...
...
common/djangoapps/entitlements/tests/test_models.py
View file @
3fbb1571
...
...
@@ -46,6 +46,10 @@ class TestModels(TestCase):
assert
entitlement
.
is_entitlement_redeemable
()
is
False
entitlement
=
CourseEntitlementFactory
.
create
(
expired_at
=
datetime
.
now
())
assert
entitlement
.
is_entitlement_refundable
()
is
False
def
test_is_entitlement_refundable
(
self
):
"""
Test that the entitlement is refundable when created now, and is not refundable when created 70 days
...
...
@@ -83,6 +87,10 @@ class TestModels(TestCase):
assert
entitlement
.
is_entitlement_refundable
()
is
True
entitlement
=
CourseEntitlementFactory
.
create
(
expired_at
=
datetime
.
now
())
assert
entitlement
.
is_entitlement_refundable
()
is
False
def
test_is_entitlement_regainable
(
self
):
"""
Test that the entitlement is not expired when created now, and is expired when created20 days
...
...
@@ -113,6 +121,10 @@ class TestModels(TestCase):
assert
entitlement
.
is_entitlement_regainable
()
is
False
entitlement
=
CourseEntitlementFactory
.
create
(
expired_at
=
datetime
.
now
())
assert
entitlement
.
is_entitlement_regainable
def
test_get_days_until_expiration
(
self
):
"""
Test that the expiration period is always less than or equal to the policy expiration
...
...
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