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
e34d131f
Commit
e34d131f
authored
Dec 12, 2013
by
Chris Rossi
Committed by
Diana Huang
Jan 16, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skeleton for emails script.
parent
883563d8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
lms/djangoapps/linkedin/management/commands/mailusers.py
+61
-0
lms/djangoapps/linkedin/models.py
+1
-0
No files found.
lms/djangoapps/linkedin/management/commands/mailusers.py
0 → 100644
View file @
e34d131f
"""
Send emails to users inviting them to add their course certificates to their
LinkedIn profiles.
"""
from
itertools
import
imap
from
django.core.management.base
import
BaseCommand
from
optparse
import
make_option
from
certificates.models
import
GeneratedCertificate
from
...models
import
LinkedIn
class
Command
(
BaseCommand
):
args
=
''
help
=
(
'Sends emails to edX users that are on LinkedIn who have completed '
'course certificates, inviting them to add their certificates to '
'their LinkedIn profiles'
)
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
'--grandfather'
,
action
=
'store_true'
,
dest
=
'grandfather'
,
default
=
False
,
help
=
"Creates aggregate invitations for all certificates a user "
"has earned to date and sends a 'grandfather' email. This is "
"intended to be used when the feature is launched to invite "
"all users that have earned certificates to date to add their "
"certificates. Afterwards the default, one email per "
"certificate mail form will be used."
),)
def
handle
(
self
,
*
args
,
**
options
):
grandfather
=
options
.
get
(
'grandfather'
,
False
)
accounts
=
LinkedIn
.
objects
.
filter
(
has_linkedin_account
=
True
)
for
user
in
imap
(
lambda
account
:
account
.
user
,
accounts
):
# lazy
certificates
=
GeneratedCertificate
.
objects
.
filter
(
user
=
user
)
certificates
=
certificates
.
filter
(
status
=
'downloadable'
)
if
not
certificates
:
continue
if
grandfather
:
send_grandfather_email
(
user
,
certificates
)
else
:
for
certificate
in
certificates
:
send_email
(
user
,
certificate
)
def
send_grandfather_email
(
user
,
certificates
):
"""
Send the 'grandfathered' email informing historical students that they may
now post their certificates on their LinkedIn profiles.
"""
print
"GRANDFATHER: "
,
user
,
certificates
def
send_email
(
user
,
certificate
):
"""
Email a user that recently earned a certificate, inviting them to post their
certificate on their LinkedIn profile.
"""
print
"EMAIL: "
,
user
,
certificate
lms/djangoapps/linkedin/models.py
View file @
e34d131f
...
@@ -11,3 +11,4 @@ class LinkedIn(models.Model):
...
@@ -11,3 +11,4 @@ class LinkedIn(models.Model):
"""
"""
user
=
models
.
OneToOneField
(
User
,
primary_key
=
True
)
user
=
models
.
OneToOneField
(
User
,
primary_key
=
True
)
has_linkedin_account
=
models
.
NullBooleanField
(
default
=
None
)
has_linkedin_account
=
models
.
NullBooleanField
(
default
=
None
)
emailed_courses
=
models
.
TextField
(
default
=
"[]"
)
# JSON list of course ids
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