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
88b83c42
Commit
88b83c42
authored
Jun 21, 2013
by
Sarina Canelake
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #235 from edx/sarina/fix-reactivation-email-bug
Fix 500 error on reactivation email
parents
30593b37
8201ca5e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
13 deletions
+30
-13
common/djangoapps/student/tests/test_email.py
+19
-6
common/djangoapps/student/views.py
+11
-7
No files found.
common/djangoapps/student/tests/test_email.py
View file @
88b83c42
...
@@ -55,11 +55,15 @@ class ReactivationEmailTests(EmailTestMixin, TestCase):
...
@@ -55,11 +55,15 @@ class ReactivationEmailTests(EmailTestMixin, TestCase):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
user
=
UserFactory
.
create
()
self
.
user
=
UserFactory
.
create
()
self
.
unregisteredUser
=
UserFactory
.
create
()
self
.
registration
=
RegistrationFactory
.
create
(
user
=
self
.
user
)
self
.
registration
=
RegistrationFactory
.
create
(
user
=
self
.
user
)
def
reactivation_email
(
self
):
def
reactivation_email
(
self
,
user
):
"""Send the reactivation email, and return the response as json data"""
"""
return
json
.
loads
(
reactivation_email_for_user
(
self
.
user
)
.
content
)
Send the reactivation email to the specified user,
and return the response as json data.
"""
return
json
.
loads
(
reactivation_email_for_user
(
user
)
.
content
)
def
assertReactivateEmailSent
(
self
,
email_user
):
def
assertReactivateEmailSent
(
self
,
email_user
):
"""Assert that the correct reactivation email has been sent"""
"""Assert that the correct reactivation email has been sent"""
...
@@ -78,13 +82,22 @@ class ReactivationEmailTests(EmailTestMixin, TestCase):
...
@@ -78,13 +82,22 @@ class ReactivationEmailTests(EmailTestMixin, TestCase):
def
test_reactivation_email_failure
(
self
,
email_user
):
def
test_reactivation_email_failure
(
self
,
email_user
):
self
.
user
.
email_user
.
side_effect
=
Exception
self
.
user
.
email_user
.
side_effect
=
Exception
response_data
=
self
.
reactivation_email
()
response_data
=
self
.
reactivation_email
(
self
.
user
)
self
.
assertReactivateEmailSent
(
email_user
)
self
.
assertReactivateEmailSent
(
email_user
)
self
.
assertFalse
(
response_data
[
'success'
])
self
.
assertFalse
(
response_data
[
'success'
])
def
test_reactivation_for_unregistered_user
(
self
,
email_user
):
"""
Test that trying to send a reactivation email to an unregistered
user fails without throwing a 500 error.
"""
response_data
=
self
.
reactivation_email
(
self
.
unregisteredUser
)
self
.
assertFalse
(
response_data
[
'success'
])
def
test_reactivation_email_success
(
self
,
email_user
):
def
test_reactivation_email_success
(
self
,
email_user
):
response_data
=
self
.
reactivation_email
()
response_data
=
self
.
reactivation_email
(
self
.
user
)
self
.
assertReactivateEmailSent
(
email_user
)
self
.
assertReactivateEmailSent
(
email_user
)
self
.
assertTrue
(
response_data
[
'success'
])
self
.
assertTrue
(
response_data
[
'success'
])
...
@@ -150,7 +163,7 @@ class EmailChangeRequestTests(TestCase):
...
@@ -150,7 +163,7 @@ class EmailChangeRequestTests(TestCase):
self
.
check_duplicate_email
(
self
.
new_email
)
self
.
check_duplicate_email
(
self
.
new_email
)
def
test_capitalized_duplicate_email
(
self
):
def
test_capitalized_duplicate_email
(
self
):
raise
SkipTest
(
"We currently don't check for emails in a case insensitive way, but we should"
)
"""Test that we check for email addresses in a case insensitive way"""
UserFactory
.
create
(
email
=
self
.
new_email
)
UserFactory
.
create
(
email
=
self
.
new_email
)
self
.
check_duplicate_email
(
self
.
new_email
.
capitalize
())
self
.
check_duplicate_email
(
self
.
new_email
.
capitalize
())
...
...
common/djangoapps/student/views.py
View file @
88b83c42
...
@@ -176,7 +176,7 @@ def _cert_info(user, course, cert_status):
...
@@ -176,7 +176,7 @@ def _cert_info(user, course, cert_status):
CertificateStatuses
.
downloadable
:
'ready'
,
CertificateStatuses
.
downloadable
:
'ready'
,
CertificateStatuses
.
notpassing
:
'notpassing'
,
CertificateStatuses
.
notpassing
:
'notpassing'
,
CertificateStatuses
.
restricted
:
'restricted'
,
CertificateStatuses
.
restricted
:
'restricted'
,
}
}
status
=
template_state
.
get
(
cert_status
[
'status'
],
default_status
)
status
=
template_state
.
get
(
cert_status
[
'status'
],
default_status
)
...
@@ -185,10 +185,10 @@ def _cert_info(user, course, cert_status):
...
@@ -185,10 +185,10 @@ def _cert_info(user, course, cert_status):
'show_disabled_download_button'
:
status
==
'generating'
,
}
'show_disabled_download_button'
:
status
==
'generating'
,
}
if
(
status
in
(
'generating'
,
'ready'
,
'notpassing'
,
'restricted'
)
and
if
(
status
in
(
'generating'
,
'ready'
,
'notpassing'
,
'restricted'
)
and
course
.
end_of_course_survey_url
is
not
None
):
course
.
end_of_course_survey_url
is
not
None
):
d
.
update
({
d
.
update
({
'show_survey_button'
:
True
,
'show_survey_button'
:
True
,
'survey_url'
:
process_survey_link
(
course
.
end_of_course_survey_url
,
user
)})
'survey_url'
:
process_survey_link
(
course
.
end_of_course_survey_url
,
user
)})
else
:
else
:
d
[
'show_survey_button'
]
=
False
d
[
'show_survey_button'
]
=
False
...
@@ -913,8 +913,8 @@ def get_random_post_override():
...
@@ -913,8 +913,8 @@ def get_random_post_override():
'password'
:
id_generator
(),
'password'
:
id_generator
(),
'name'
:
(
id_generator
(
size
=
5
,
chars
=
string
.
ascii_lowercase
)
+
" "
+
'name'
:
(
id_generator
(
size
=
5
,
chars
=
string
.
ascii_lowercase
)
+
" "
+
id_generator
(
size
=
7
,
chars
=
string
.
ascii_lowercase
)),
id_generator
(
size
=
7
,
chars
=
string
.
ascii_lowercase
)),
'honor_code'
:
u'true'
,
'honor_code'
:
u'true'
,
'terms_of_service'
:
u'true'
,
}
'terms_of_service'
:
u'true'
,
}
def
create_random_account
(
create_account_function
):
def
create_random_account
(
create_account_function
):
...
@@ -986,7 +986,11 @@ def password_reset(request):
...
@@ -986,7 +986,11 @@ def password_reset(request):
def
reactivation_email_for_user
(
user
):
def
reactivation_email_for_user
(
user
):
reg
=
Registration
.
objects
.
get
(
user
=
user
)
try
:
reg
=
Registration
.
objects
.
get
(
user
=
user
)
except
Registration
.
DoesNotExist
:
return
HttpResponse
(
json
.
dumps
({
'success'
:
False
,
'error'
:
'No inactive user with this e-mail exists'
}))
d
=
{
'name'
:
user
.
profile
.
name
,
d
=
{
'name'
:
user
.
profile
.
name
,
'key'
:
reg
.
activation_key
}
'key'
:
reg
.
activation_key
}
...
...
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