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
77a315c6
Commit
77a315c6
authored
Jan 16, 2014
by
David Ormsbee
Committed by
Diana Huang
Jan 16, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor data collection tweaks after examining prod course data.
Add in unicode handling for names.
parent
2b665152
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
7 deletions
+25
-7
lms/djangoapps/linkedin/management/commands/linkedin_mailusers.py
+5
-5
lms/djangoapps/linkedin/management/commands/tests/test_mailusers.py
+20
-2
No files found.
lms/djangoapps/linkedin/management/commands/linkedin_mailusers.py
View file @
77a315c6
...
...
@@ -191,11 +191,11 @@ class Command(BaseCommand):
reverse
(
'course_root'
,
kwargs
=
{
'course_id'
:
cert
.
course_id
})
)
course_title
=
course
.
display_name
course_title
=
course
.
display_name
_with_default
course_img_url
=
'https://{}{}'
.
format
(
settings
.
SITE_NAME
,
course_image_url
(
course
))
course_end_date
=
course
.
end
.
strftime
(
'
%
b
%
Y'
)
course_org
=
course
.
display_organization
course_org
=
course
.
org
courses_list
.
append
({
'course_url'
:
course_url
,
...
...
@@ -208,7 +208,7 @@ class Command(BaseCommand):
context
=
{
'courses_list'
:
courses_list
,
'num_courses'
:
len
(
courses_list
)}
body
=
render_to_string
(
'linkedin/linkedin_email.html'
,
context
)
subject
=
'{}, Add your Achievements to your LinkedIn Profile'
.
format
(
user
.
profile
.
name
)
subject
=
u
'{}, Add your Achievements to your LinkedIn Profile'
.
format
(
user
.
profile
.
name
)
if
mock_run
:
return
True
else
:
...
...
@@ -219,7 +219,7 @@ class Command(BaseCommand):
Send an email. Return True if it succeeded, False if it didn't.
"""
fromaddr
=
settings
.
DEFAULT_FROM_EMAIL
toaddr
=
'
%
s <
%
s>'
%
(
user
.
profile
.
name
,
user
.
email
)
toaddr
=
u'{} <{}>'
.
format
(
user
.
profile
.
name
,
user
.
email
)
msg
=
EmailMessage
(
subject
,
body
,
fromaddr
,
(
toaddr
,))
msg
.
content_subtype
=
"html"
...
...
@@ -231,7 +231,7 @@ class Command(BaseCommand):
except
SINGLE_EMAIL_FAILURE_ERRORS
:
# Something unrecoverable is wrong about the email acct we're sending to
log
.
exception
(
"LinkedIn: Email send failed for user {}, email {}"
u
"LinkedIn: Email send failed for user {}, email {}"
.
format
(
user
.
username
,
user
.
email
)
)
return
False
...
...
lms/djangoapps/linkedin/management/commands/tests/test_mailusers.py
View file @
77a315c6
# -*- coding: utf-8 -*-
"""
Test email scripts.
"""
...
...
@@ -51,9 +52,16 @@ class MailusersTests(TestCase):
self
.
barney
=
barney
=
User
(
username
=
'barney'
,
email
=
'barney@bedrock.gov'
)
barney
.
save
()
LinkedIn
(
user
=
barney
,
has_linkedin_account
=
True
)
.
save
()
UserProfile
(
user
=
barney
,
name
=
'Barney Rubble'
)
.
save
()
self
.
adam
=
adam
=
User
(
username
=
'adam'
,
email
=
'adam@adam.gov'
)
adam
.
save
()
LinkedIn
(
user
=
adam
,
has_linkedin_account
=
True
)
.
save
()
UserProfile
(
user
=
adam
,
name
=
'Adam (חיים פּלי)'
)
.
save
()
self
.
cert1
=
cert1
=
GeneratedCertificate
(
status
=
'downloadable'
,
user
=
fred
,
...
...
@@ -71,7 +79,11 @@ class MailusersTests(TestCase):
user
=
barney
,
course_id
=
'TESTX/3/TEST3'
)
cert3
.
save
()
cert5
=
GeneratedCertificate
(
status
=
'downloadable'
,
user
=
adam
,
course_id
=
'TESTX/3/TEST3'
)
cert5
.
save
()
@mock.patch.dict
(
'django.conf.settings.LINKEDIN_API'
,
{
'EMAIL_WHITELIST'
:
[
'barney@bedrock.gov'
]})
...
...
@@ -97,7 +109,9 @@ class MailusersTests(TestCase):
json
.
loads
(
self
.
fred
.
linkedin
.
emailed_courses
),
[
'TESTX/1/TEST1'
,
'TESTX/2/TEST2'
])
self
.
assertEqual
(
json
.
loads
(
self
.
barney
.
linkedin
.
emailed_courses
),
[
'TESTX/3/TEST3'
])
self
.
assertEqual
(
len
(
mail
.
outbox
),
2
)
self
.
assertEqual
(
json
.
loads
(
self
.
adam
.
linkedin
.
emailed_courses
),
[
'TESTX/3/TEST3'
])
self
.
assertEqual
(
len
(
mail
.
outbox
),
3
)
self
.
assertEqual
(
mail
.
outbox
[
0
]
.
to
,
[
'Fred Flintstone <fred@bedrock.gov>'
])
self
.
assertEqual
(
...
...
@@ -106,6 +120,8 @@ class MailusersTests(TestCase):
mail
.
outbox
[
1
]
.
to
,
[
'Barney Rubble <barney@bedrock.gov>'
])
self
.
assertEqual
(
mail
.
outbox
[
1
]
.
subject
,
'Barney Rubble, Add your Achievements to your LinkedIn Profile'
)
self
.
assertEqual
(
mail
.
outbox
[
2
]
.
subject
,
u'Adam (חיים פּלי), Add your Achievements to your LinkedIn Profile'
)
def
test_mail_users_grandfather_mock
(
self
):
"""
...
...
@@ -117,6 +133,8 @@ class MailusersTests(TestCase):
json
.
loads
(
self
.
fred
.
linkedin
.
emailed_courses
),
[])
self
.
assertEqual
(
json
.
loads
(
self
.
barney
.
linkedin
.
emailed_courses
),
[])
self
.
assertEqual
(
json
.
loads
(
self
.
adam
.
linkedin
.
emailed_courses
),
[])
self
.
assertEqual
(
len
(
mail
.
outbox
),
0
)
def
test_transaction_semantics
(
self
):
...
...
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