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
8201ca5e
Commit
8201ca5e
authored
Jun 20, 2013
by
Sarina Canelake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix 500 error on reactivation email
parent
51469ad3
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 @
8201ca5e
...
...
@@ -55,11 +55,15 @@ class ReactivationEmailTests(EmailTestMixin, TestCase):
def
setUp
(
self
):
self
.
user
=
UserFactory
.
create
()
self
.
unregisteredUser
=
UserFactory
.
create
()
self
.
registration
=
RegistrationFactory
.
create
(
user
=
self
.
user
)
def
reactivation_email
(
self
):
"""Send the reactivation email, and return the response as json data"""
return
json
.
loads
(
reactivation_email_for_user
(
self
.
user
)
.
content
)
def
reactivation_email
(
self
,
user
):
"""
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
):
"""Assert that the correct reactivation email has been sent"""
...
...
@@ -78,13 +82,22 @@ class ReactivationEmailTests(EmailTestMixin, TestCase):
def
test_reactivation_email_failure
(
self
,
email_user
):
self
.
user
.
email_user
.
side_effect
=
Exception
response_data
=
self
.
reactivation_email
()
response_data
=
self
.
reactivation_email
(
self
.
user
)
self
.
assertReactivateEmailSent
(
email_user
)
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
):
response_data
=
self
.
reactivation_email
()
response_data
=
self
.
reactivation_email
(
self
.
user
)
self
.
assertReactivateEmailSent
(
email_user
)
self
.
assertTrue
(
response_data
[
'success'
])
...
...
@@ -150,7 +163,7 @@ class EmailChangeRequestTests(TestCase):
self
.
check_duplicate_email
(
self
.
new_email
)
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
)
self
.
check_duplicate_email
(
self
.
new_email
.
capitalize
())
...
...
common/djangoapps/student/views.py
View file @
8201ca5e
...
...
@@ -174,7 +174,7 @@ def _cert_info(user, course, cert_status):
CertificateStatuses
.
downloadable
:
'ready'
,
CertificateStatuses
.
notpassing
:
'notpassing'
,
CertificateStatuses
.
restricted
:
'restricted'
,
}
}
status
=
template_state
.
get
(
cert_status
[
'status'
],
default_status
)
...
...
@@ -183,10 +183,10 @@ def _cert_info(user, course, cert_status):
'show_disabled_download_button'
:
status
==
'generating'
,
}
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
({
'show_survey_button'
:
True
,
'survey_url'
:
process_survey_link
(
course
.
end_of_course_survey_url
,
user
)})
'show_survey_button'
:
True
,
'survey_url'
:
process_survey_link
(
course
.
end_of_course_survey_url
,
user
)})
else
:
d
[
'show_survey_button'
]
=
False
...
...
@@ -881,8 +881,8 @@ def get_random_post_override():
'password'
:
id_generator
(),
'name'
:
(
id_generator
(
size
=
5
,
chars
=
string
.
ascii_lowercase
)
+
" "
+
id_generator
(
size
=
7
,
chars
=
string
.
ascii_lowercase
)),
'honor_code'
:
u'true'
,
'terms_of_service'
:
u'true'
,
}
'honor_code'
:
u'true'
,
'terms_of_service'
:
u'true'
,
}
def
create_random_account
(
create_account_function
):
...
...
@@ -967,7 +967,11 @@ def reactivation_email(request):
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
,
'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