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
b74e964d
Commit
b74e964d
authored
Sep 27, 2016
by
Awais Jibran
Committed by
GitHub
Sep 27, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Fix user registration "
parent
2845b66d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
17 deletions
+8
-17
common/djangoapps/student/tasks.py
+1
-3
common/djangoapps/student/tests/test_tasks.py
+6
-13
common/djangoapps/student/views.py
+1
-1
No files found.
common/djangoapps/student/tasks.py
View file @
b74e964d
...
...
@@ -2,7 +2,6 @@
This file contains celery tasks for sending email
"""
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.core
import
mail
from
celery.task
import
task
# pylint: disable=no-name-in-module, import-error
...
...
@@ -13,11 +12,10 @@ log = get_task_logger(__name__)
@task
(
bind
=
True
)
def
send_activation_email
(
self
,
user
_id
,
subject
,
message
,
from_address
):
def
send_activation_email
(
self
,
user
,
subject
,
message
,
from_address
):
"""
Sending an activation email to the users.
"""
user
=
User
.
objects
.
get
(
id
=
user_id
)
max_retries
=
settings
.
RETRY_ACTIVATION_EMAIL_MAX_ATTEMPTS
retries
=
self
.
request
.
retries
+
1
dest_addr
=
user
.
email
...
...
common/djangoapps/student/tests/test_tasks.py
View file @
b74e964d
...
...
@@ -9,36 +9,29 @@ from django.conf import settings
from
student.tasks
import
send_activation_email
from
boto.exception
import
NoAuthHandlerFound
from
lms.djangoapps.courseware.tests.factories
import
UserFactory
class
SendActivationEmailTestCase
(
TestCase
):
"""
Test for send activation email to user
"""
def
setUp
(
self
):
""" Setup components used by each test."""
super
(
SendActivationEmailTestCase
,
self
)
.
setUp
()
self
.
student
=
UserFactory
()
@mock.patch
(
'time.sleep'
,
mock
.
Mock
(
return_value
=
None
))
@mock.patch
(
'student.tasks.log'
)
@mock.patch
(
'django.contrib.auth.models.User
.email_user'
,
mock
.
Mock
(
side_effect
=
NoAuthHandlerFound
)
)
def
test_send_email
(
self
,
mock_log
):
@mock.patch
(
'django.contrib.auth.models.User
'
)
def
test_send_email
(
self
,
mock_
user
,
mock_
log
):
"""
Tests retries when the activation email doesn't send
"""
from_address
=
'task_testing@edX.com'
mock_user
.
email_user
.
side_effect
=
NoAuthHandlerFound
email_max_attempts
=
settings
.
RETRY_ACTIVATION_EMAIL_MAX_ATTEMPTS
+
1
# pylint: disable=no-member
send_activation_email
.
delay
(
self
.
student
.
id
,
'Task_test'
,
'Task_test_message'
,
from_address
)
send_activation_email
.
delay
(
mock_user
,
'Task_test'
,
'Task_test_message'
,
from_address
)
# Asserts sending email retry logging.
for
attempt
in
xrange
(
1
,
email_max_attempts
):
mock_log
.
info
.
assert_any_call
(
'Retrying sending email to user {dest_addr}, attempt # {attempt} of {max_attempts}'
.
format
(
dest_addr
=
self
.
student
.
email
,
dest_addr
=
mock_user
.
email
,
attempt
=
attempt
,
max_attempts
=
email_max_attempts
))
...
...
@@ -48,7 +41,7 @@ class SendActivationEmailTestCase(TestCase):
mock_log
.
error
.
assert_called_with
(
'Unable to send activation email to user from "
%
s" to "
%
s"'
,
from_address
,
self
.
student
.
email
,
mock_user
.
email
,
exc_info
=
True
)
self
.
assertEquals
(
mock_log
.
error
.
call_count
,
1
)
common/djangoapps/student/views.py
View file @
b74e964d
...
...
@@ -1790,7 +1790,7 @@ def create_account_with_params(request, params):
'email_from_address'
,
settings
.
DEFAULT_FROM_EMAIL
)
send_activation_email
.
delay
(
user
.
id
,
subject
,
message
,
from_address
)
send_activation_email
.
delay
(
user
,
subject
,
message
,
from_address
)
else
:
registration
.
activate
()
_enroll_user_in_pending_courses
(
user
)
# Enroll student in any pending courses
...
...
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