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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
44 deletions
+40
-44
common/djangoapps/entitlements/api/v1/views.py
+40
-44
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
"""
"""
save_model
=
False
log
.
info
(
if
instance
.
expired_at
is
None
:
'Entitlement Revoke requested for Course Entitlement[
%
s]'
,
instance
.
expired_at
=
timezone
.
now
()
str
(
instance
.
uuid
)
log
.
info
(
'Set expired_at to [
%
s] for course entitlement [
%
s]'
,
instance
.
expired_at
,
instance
.
uuid
)
)
save_model
=
True
process_revoke_and_unenroll_entitlement
(
instance
)
if
instance
.
enrollment_course_run
is
not
None
:
CourseEnrollment
.
unenroll
(
@transaction.atomic
user
=
instance
.
user
,
def
process_revoke_and_unenroll_entitlement
(
course_entitlement
):
course_id
=
instance
.
enrollment_course_run
.
course_id
,
save_model
=
False
skip_refund
=
True
)
if
course_entitlement
.
expired_at
is
None
:
enrollment
=
instance
.
enrollment_course_run
course_entitlement
.
expired_at
=
timezone
.
now
()
instance
.
enrollment_course_run
=
None
log
.
info
(
'Set expired_at to [
%
s] for course entitlement [
%
s]'
,
course_entitlement
.
expired_at
,
course_entitlement
.
uuid
)
save_model
=
True
save_model
=
True
log
.
info
(
'Unenrolled user [
%
s] from course run [
%
s] as part of revocation of course entitlement [
%
s]'
,
if
course_entitlement
.
enrollment_course_run
is
not
None
:
instance
.
user
.
username
,
CourseEnrollment
.
unenroll
(
enrollment
.
course_id
,
user
=
course_entitlement
.
user
,
instance
.
uuid
course_id
=
course_entitlement
.
enrollment_course_run
.
course_id
,
)
skip_refund
=
True
if
save_model
:
)
instance
.
save
()
enrollment
=
course_entitlement
.
enrollment_course_run
course_entitlement
.
enrollment_course_run
=
None
save_model
=
True
log
.
info
(
'Unenrolled user [
%
s] from course run [
%
s] as part of revocation of course entitlement [
%
s]'
,
course_entitlement
.
user
.
username
,
enrollment
.
course_id
,
course_entitlement
.
uuid
)
if
save_model
:
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
:
if
refund_successful
:
with
transaction
.
atomic
():
process_revoke_and_unenroll_entitlement
(
course_entitlement
=
entitlement
)
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
entitlement
.
enrollment_course_run
is
not
None
:
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