Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
365b4fb3
Unverified
Commit
365b4fb3
authored
7 years ago
by
Albert (AJ) St. Aubin
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #16920 from edx/aj/add_is_expired_check_to_policy
Aj/add is expired check to policy
parents
b6030a4b
3fbb1571
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/djangoapps/entitlements/models.py
+9
-1
9 additions, 1 deletion
common/djangoapps/entitlements/models.py
common/djangoapps/entitlements/tests/test_models.py
+12
-0
12 additions, 0 deletions
common/djangoapps/entitlements/tests/test_models.py
with
21 additions
and
1 deletion
common/djangoapps/entitlements/models.py
+
9
−
1
View file @
365b4fb3
...
...
@@ -71,6 +71,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
:
...
...
@@ -87,6 +90,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
...
...
@@ -109,7 +116,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: {}
'
\
...
...
This diff is collapsed.
Click to expand it.
common/djangoapps/entitlements/tests/test_models.py
+
12
−
0
View file @
365b4fb3
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment