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
5903ec5b
Commit
5903ec5b
authored
May 02, 2014
by
Usman Khalid
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3417 from edx/usman/lms2518-refund-emails
Parameter from_email to send_mail() should be string
parents
c51f7378
e33e9ff2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
8 deletions
+35
-8
lms/djangoapps/shoppingcart/models.py
+7
-7
lms/djangoapps/shoppingcart/tests/test_models.py
+28
-1
No files found.
lms/djangoapps/shoppingcart/models.py
View file @
5903ec5b
...
...
@@ -478,19 +478,19 @@ class CertificateItem(OrderItem):
user_email
=
course_enrollment
.
user
.
email
,
order_number
=
order_number
)
to_email
=
[
settings
.
PAYMENT_SUPPORT_EMAIL
]
from_email
=
[
microsite
.
get_value
(
'payment_support_email'
,
settings
.
PAYMENT_SUPPORT_EMAIL
)]
from_email
=
microsite
.
get_value
(
'payment_support_email'
,
settings
.
PAYMENT_SUPPORT_EMAIL
)
try
:
send_mail
(
subject
,
message
,
from_email
,
to_email
,
fail_silently
=
False
)
except
(
smtplib
.
SMTPException
,
BotoServerError
):
err_str
=
'Failed sending email to billing request a refund for verified certiciate (User {user}, Course {course}, CourseEnrollmentID {ce_id}, Order #{order})'
except
Exception
as
exception
:
# pylint: disable=broad-except
err_str
=
(
'Failed sending email to billing to request a refund for verified certificate'
' (User {user}, Course {course}, CourseEnrollmentID {ce_id}, Order #{order})
\n
{exception}'
)
log
.
error
(
err_str
.
format
(
user
=
course_enrollment
.
user
,
course
=
course_enrollment
.
course_id
,
ce_id
=
course_enrollment
.
id
,
order
=
order_number
))
order
=
order_number
,
exception
=
exception
,
))
return
target_cert
...
...
lms/djangoapps/shoppingcart/tests/test_models.py
View file @
5903ec5b
...
...
@@ -405,6 +405,33 @@ class CertificateItemTest(ModuleStoreTestCase):
self
.
assertTrue
(
target_certs
[
0
]
.
refund_requested_time
)
self
.
assertEquals
(
target_certs
[
0
]
.
order
.
status
,
'refunded'
)
def
test_refund_cert_callback_before_expiration_email
(
self
):
""" Test that refund emails are being sent correctly. """
course_id
=
"refund_before_expiration/test/one"
many_days
=
datetime
.
timedelta
(
days
=
60
)
CourseFactory
.
create
(
org
=
'refund_before_expiration'
,
number
=
'test'
,
run
=
'course'
,
display_name
=
'one'
)
course_mode
=
CourseMode
(
course_id
=
course_id
,
mode_slug
=
"verified"
,
mode_display_name
=
"verified cert"
,
min_price
=
self
.
cost
,
expiration_datetime
=
datetime
.
datetime
.
now
(
pytz
.
utc
)
+
many_days
)
course_mode
.
save
()
CourseEnrollment
.
enroll
(
self
.
user
,
course_id
,
'verified'
)
cart
=
Order
.
get_cart_for_user
(
user
=
self
.
user
)
CertificateItem
.
add_to_order
(
cart
,
course_id
,
self
.
cost
,
'verified'
)
cart
.
purchase
()
mail
.
outbox
=
[]
with
patch
(
'shoppingcart.models.log.error'
)
as
mock_error_logger
:
CourseEnrollment
.
unenroll
(
self
.
user
,
course_id
)
self
.
assertFalse
(
mock_error_logger
.
called
)
self
.
assertEquals
(
len
(
mail
.
outbox
),
1
)
self
.
assertEquals
(
'[Refund] User-Requested Refund'
,
mail
.
outbox
[
0
]
.
subject
)
self
.
assertEquals
(
settings
.
PAYMENT_SUPPORT_EMAIL
,
mail
.
outbox
[
0
]
.
from_email
)
self
.
assertIn
(
'has requested a refund on Order'
,
mail
.
outbox
[
0
]
.
body
)
@patch
(
'shoppingcart.models.log.error'
)
def
test_refund_cert_callback_before_expiration_email_error
(
self
,
error_logger
):
# If there's an error sending an email to billing, we need to log this error
...
...
@@ -426,7 +453,7 @@ class CertificateItemTest(ModuleStoreTestCase):
with
patch
(
'shoppingcart.models.send_mail'
,
side_effect
=
smtplib
.
SMTPException
):
CourseEnrollment
.
unenroll
(
self
.
user
,
course_id
)
self
.
assertTrue
(
error_logger
.
call
ed
)
self
.
assertTrue
(
error_logger
.
call
_args
[
0
][
0
]
.
startswith
(
'Failed sending email'
)
)
def
test_refund_cert_callback_after_expiration
(
self
):
# If the expiration date has passed, the user cannot get a refund
...
...
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