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
131979e1
Commit
131979e1
authored
Jul 29, 2013
by
Kevin Luo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix unicode username bug and use celery retry to get CourseEmail
Remove username from email footer.
parent
4cc758da
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
16 deletions
+9
-16
lms/djangoapps/bulk_email/tasks.py
+7
-14
lms/templates/emails/email_footer.html
+1
-1
lms/templates/emails/email_footer.txt
+1
-1
No files found.
lms/djangoapps/bulk_email/tasks.py
View file @
131979e1
...
@@ -20,7 +20,7 @@ from mitxmako.shortcuts import render_to_string
...
@@ -20,7 +20,7 @@ from mitxmako.shortcuts import render_to_string
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
@task
()
@task
(
default_retry_delay
=
10
,
max_retries
=
5
)
def
delegate_email_batches
(
hash_for_msg
,
recipient
,
course_id
,
course_url
,
user_id
):
def
delegate_email_batches
(
hash_for_msg
,
recipient
,
course_id
,
course_url
,
user_id
):
'''
'''
Delegates emails by querying for the list of recipients who should
Delegates emails by querying for the list of recipients who should
...
@@ -37,18 +37,11 @@ def delegate_email_batches(hash_for_msg, recipient, course_id, course_url, user_
...
@@ -37,18 +37,11 @@ def delegate_email_batches(hash_for_msg, recipient, course_id, course_url, user_
log
.
error
(
"get_course_by_id failed: "
+
exc
.
args
[
0
])
log
.
error
(
"get_course_by_id failed: "
+
exc
.
args
[
0
])
raise
Exception
(
"get_course_by_id failed: "
+
exc
.
args
[
0
])
raise
Exception
(
"get_course_by_id failed: "
+
exc
.
args
[
0
])
email
=
None
try
:
retries
=
0
email
=
CourseEmail
.
objects
.
get
(
hash
=
hash_for_msg
)
while
email
is
None
:
except
CourseEmail
.
DoesNotExist
as
exc
:
try
:
log
.
warning
(
"Failed to get CourseEmail with hash
%
s, retry
%
d"
%
(
hash_for_msg
,
current_task
.
request
.
retries
))
email
=
CourseEmail
.
objects
.
get
(
hash
=
hash_for_msg
)
raise
delegate_email_batches
.
retry
(
arg
=
[
hash_for_msg
,
recipient
,
course_id
,
course_url
,
user_id
],
exc
=
exc
)
except
CourseEmail
.
DoesNotExist
as
exc
:
if
retries
<
3
:
retries
+=
1
time
.
sleep
(
5
)
else
:
log
.
error
(
"Failed to get CourseEmail with hash "
+
hash_for_msg
+
", no workers fired."
)
return
0
if
recipient
==
"myself"
:
if
recipient
==
"myself"
:
recipient_qset
=
User
.
objects
.
filter
(
id
=
user_id
)
.
values
(
'profile__name'
,
'email'
)
recipient_qset
=
User
.
objects
.
filter
(
id
=
user_id
)
.
values
(
'profile__name'
,
'email'
)
...
@@ -140,7 +133,7 @@ def course_email(hash_for_msg, to_list, course_title, course_url, throttle=False
...
@@ -140,7 +133,7 @@ def course_email(hash_for_msg, to_list, course_title, course_url, throttle=False
raise
exc
# this will cause the outer handler to catch the exception and retry the entire task
raise
exc
# this will cause the outer handler to catch the exception and retry the entire task
else
:
else
:
#this will fall through and not retry the message, since it will be popped
#this will fall through and not retry the message, since it will be popped
log
.
warn
(
'Email with hash '
+
hash_for_msg
+
' not delivered to '
+
email
+
' due to error: '
+
exc
.
smtp_error
)
log
.
warn
ing
(
'Email with hash '
+
hash_for_msg
+
' not delivered to '
+
email
+
' due to error: '
+
exc
.
smtp_error
)
num_error
+=
1
num_error
+=
1
to_list
.
pop
()
to_list
.
pop
()
...
...
lms/templates/emails/email_footer.html
View file @
131979e1
<
%!
from
django
.
core
.
urlresolvers
import
reverse
%
>
<
%!
from
django
.
core
.
urlresolvers
import
reverse
%
>
<br
/>
<br
/>
----
<br
/>
----
<br
/>
This email was automatically sent from ${settings.PLATFORM_NAME}
to ${name}
.
<br
/>
This email was automatically sent from ${settings.PLATFORM_NAME}.
<br
/>
You are receiving this email at address ${ email } because you are enrolled in
<a
href=
"${course_url}"
>
${ course_title }
</a>
.
<br
/>
You are receiving this email at address ${ email } because you are enrolled in
<a
href=
"${course_url}"
>
${ course_title }
</a>
.
<br
/>
To stop receiving email like this, update your course email settings
<a
href=
"https://${settings.SITE_NAME}${reverse('dashboard')}"
>
here
</a>
.
<br
/>
To stop receiving email like this, update your course email settings
<a
href=
"https://${settings.SITE_NAME}${reverse('dashboard')}"
>
here
</a>
.
<br
/>
lms/templates/emails/email_footer.txt
View file @
131979e1
<%! from django.core.urlresolvers import reverse %>
<%! from django.core.urlresolvers import reverse %>
----
----
This email was automatically sent from ${settings.PLATFORM_NAME}
to ${name}
.
This email was automatically sent from ${settings.PLATFORM_NAME}.
You are receiving this email at address ${ email } because you are enrolled in ${ course_title }
You are receiving this email at address ${ email } because you are enrolled in ${ course_title }
(URL: ${course_url} ).
(URL: ${course_url} ).
To stop receiving email like this, update your account settings at https://${settings.SITE_NAME}${reverse('dashboard')}.
To stop receiving email like this, update your account settings at https://${settings.SITE_NAME}${reverse('dashboard')}.
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