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
f4b2c197
Commit
f4b2c197
authored
Jun 05, 2015
by
jsa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don’t trigger a refund request in otto, if otto requested unenrollment.
XCOM-396
parent
445d0dab
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
lms/djangoapps/commerce/signals.py
+8
-0
lms/djangoapps/commerce/tests/test_signals.py
+7
-0
No files found.
lms/djangoapps/commerce/signals.py
View file @
f4b2c197
...
...
@@ -5,6 +5,7 @@ import logging
from
urlparse
import
urljoin
from
django.conf
import
settings
from
django.contrib.auth.models
import
AnonymousUser
from
django.core.mail
import
EmailMultiAlternatives
from
django.dispatch
import
receiver
from
django.utils.translation
import
ugettext
as
_
...
...
@@ -32,6 +33,13 @@ def handle_unenroll_done(sender, course_enrollment=None, skip_refund=False, **kw
if
course_enrollment
and
course_enrollment
.
refundable
():
try
:
request_user
=
get_request_user
()
or
course_enrollment
.
user
if
isinstance
(
request_user
,
AnonymousUser
):
# Assume the request was initiated via server-to-server
# api call (presumably Otto). In this case we cannot
# construct a client to call Otto back anyway, because
# the client does not work anonymously, and furthermore,
# there's certainly no need to inform Otto about this request.
return
refund_seat
(
course_enrollment
,
request_user
)
except
:
# pylint: disable=bare-except
# don't assume the signal was fired with `send_robust`.
...
...
lms/djangoapps/commerce/tests/test_signals.py
View file @
f4b2c197
"""
Tests for signal handling in commerce djangoapp.
"""
from
django.contrib.auth.models
import
AnonymousUser
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
...
...
@@ -109,6 +110,12 @@ class TestRefundSignal(TestCase):
self
.
assertTrue
(
mock_refund_seat
.
called
)
self
.
assertEqual
(
mock_refund_seat
.
call_args
[
0
],
(
self
.
course_enrollment
,
self
.
requester
))
# HTTP user is another server (AnonymousUser): do not try to initiate a refund at all.
mock_get_request_user
.
return_value
=
AnonymousUser
()
mock_refund_seat
.
reset_mock
()
self
.
send_signal
()
self
.
assertFalse
(
mock_refund_seat
.
called
)
@mock.patch
(
'commerce.signals.log.warning'
)
def
test_not_authorized_warning
(
self
,
mock_log_warning
):
"""
...
...
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