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
OpenEdx
edx-platform
Commits
6c03534f
Commit
6c03534f
authored
Dec 19, 2017
by
Albert St. Aubin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PR Updates 1
parent
c25a20c5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
31 deletions
+27
-31
common/djangoapps/entitlements/api/v1/views.py
+27
-31
No files found.
common/djangoapps/entitlements/api/v1/views.py
View file @
6c03534f
...
@@ -86,30 +86,42 @@ class EntitlementViewSet(viewsets.ModelViewSet):
...
@@ -86,30 +86,42 @@ class EntitlementViewSet(viewsets.ModelViewSet):
def
perform_destroy
(
self
,
instance
):
def
perform_destroy
(
self
,
instance
):
"""
"""
This method is an override and is called by the DELETE method
This method is an override and is called by the DELETE method
This method will revoke and
"""
"""
log
.
info
(
'Entitlement Revoke requested for Course Entitlement[
%
s]'
,
str
(
instance
.
uuid
)
)
process_revoke_and_unenroll_entitlement
(
instance
)
@transaction.atomic
def
process_revoke_and_unenroll_entitlement
(
course_entitlement
):
save_model
=
False
save_model
=
False
if
instance
.
expired_at
is
None
:
instance
.
expired_at
=
timezone
.
now
()
if
course_entitlement
.
expired_at
is
None
:
log
.
info
(
'Set expired_at to [
%
s] for course entitlement [
%
s]'
,
instance
.
expired_at
,
instance
.
uuid
)
course_entitlement
.
expired_at
=
timezone
.
now
()
log
.
info
(
'Set expired_at to [
%
s] for course entitlement [
%
s]'
,
course_entitlement
.
expired_at
,
course_entitlement
.
uuid
)
save_model
=
True
save_model
=
True
if
instance
.
enrollment_course_run
is
not
None
:
if
course_entitlement
.
enrollment_course_run
is
not
None
:
CourseEnrollment
.
unenroll
(
CourseEnrollment
.
unenroll
(
user
=
instance
.
user
,
user
=
course_entitlement
.
user
,
course_id
=
instance
.
enrollment_course_run
.
course_id
,
course_id
=
course_entitlement
.
enrollment_course_run
.
course_id
,
skip_refund
=
True
skip_refund
=
True
)
)
enrollment
=
instance
.
enrollment_course_run
enrollment
=
course_entitlement
.
enrollment_course_run
instance
.
enrollment_course_run
=
None
course_entitlement
.
enrollment_course_run
=
None
save_model
=
True
save_model
=
True
log
.
info
(
log
.
info
(
'Unenrolled user [
%
s] from course run [
%
s] as part of revocation of course entitlement [
%
s]'
,
'Unenrolled user [
%
s] from course run [
%
s] as part of revocation of course entitlement [
%
s]'
,
instance
.
user
.
username
,
course_entitlement
.
user
.
username
,
enrollment
.
course_id
,
enrollment
.
course_id
,
instance
.
uuid
course_entitlement
.
uuid
)
)
if
save_model
:
if
save_model
:
instance
.
save
()
course_entitlement
.
save
()
class
EntitlementEnrollmentViewSet
(
viewsets
.
GenericViewSet
):
class
EntitlementEnrollmentViewSet
(
viewsets
.
GenericViewSet
):
...
@@ -279,29 +291,13 @@ class EntitlementEnrollmentViewSet(viewsets.GenericViewSet):
...
@@ -279,29 +291,13 @@ class EntitlementEnrollmentViewSet(viewsets.GenericViewSet):
'Entitlement Refund requested for Course Entitlement[
%
s]'
,
'Entitlement Refund requested for Course Entitlement[
%
s]'
,
str
(
entitlement
.
uuid
)
str
(
entitlement
.
uuid
)
)
)
refund_status
=
refund_entitlement
(
course_entitlement
=
entitlement
)
refund_successful
=
refund_entitlement
(
course_entitlement
=
entitlement
)
if
refund_status
:
with
transaction
.
atomic
():
entitlement
.
expired_at_datetime
=
timezone
.
now
()
entitlement
.
save
()
log
.
info
(
'Set expired_at to [
%
s] for course entitlement [
%
s]'
,
entitlement
.
expired_at
,
entitlement
.
uuid
)
# Revoke and refund the entitlement
if
refund_successful
:
if
entitlement
.
enrollment_course_run
is
not
None
:
process_revoke_and_unenroll_entitlement
(
course_entitlement
=
entitlement
)
self
.
_unenroll_entitlement
(
entitlement
=
entitlement
,
course_run_key
=
entitlement
.
enrollment_course_run
.
course_id
,
user
=
request
.
user
)
else
:
else
:
# This state is achieved in most cases by a failure in the ecommerce service to process the refund.
# This state is achieved in most cases by a failure in the ecommerce service to process the refund.
log
.
info
(
log
.
warn
(
'Entitlement Refund failed for Course Entitlement [
%
s], alert User'
,
'Entitlement Refund failed for Course Entitlement [
%
s], alert User'
,
str
(
entitlement
.
uuid
)
str
(
entitlement
.
uuid
)
)
)
...
...
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