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
b23e9fb6
Commit
b23e9fb6
authored
Feb 14, 2014
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2405 from edx/ned/remove-massemail
Remove unused massemail commands.
parents
86fd303f
ddf377cf
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
0 additions
and
175 deletions
+0
-175
common/djangoapps/student/management/commands/massemail.py
+0
-22
common/djangoapps/student/management/commands/massemailtxt.py
+0
-60
common/djangoapps/student/tests/emails/test_body.txt
+0
-1
common/djangoapps/student/tests/emails/test_subject.txt
+0
-1
common/djangoapps/student/tests/test_massemail.py
+0
-50
common/djangoapps/student/tests/test_massemail_users.txt
+0
-2
lms/templates/emails/welcome_body.txt
+0
-32
lms/templates/emails/welcome_subject.txt
+0
-7
No files found.
common/djangoapps/student/management/commands/massemail.py
deleted
100644 → 0
View file @
86fd303f
from
django.core.management.base
import
BaseCommand
from
django.contrib.auth.models
import
User
from
edxmako
import
lookup_template
class
Command
(
BaseCommand
):
help
=
\
'''Sends an e-mail to all users. Takes a single
parameter -- name of e-mail template -- located
in templates/email. Adds a .txt for the message
body, and an _subject.txt for the subject. '''
def
handle
(
self
,
*
args
,
**
options
):
#text = open(args[0]).read()
#subject = open(args[1]).read()
users
=
User
.
objects
.
all
()
text
=
lookup_template
(
'main'
,
'email/'
+
args
[
0
]
+
".txt"
)
.
render
()
subject
=
lookup_template
(
'main'
,
'email/'
+
args
[
0
]
+
"_subject.txt"
)
.
render
()
.
strip
()
for
user
in
users
:
if
user
.
is_active
:
user
.
email_user
(
subject
,
text
)
common/djangoapps/student/management/commands/massemailtxt.py
deleted
100644 → 0
View file @
86fd303f
import
os.path
import
time
from
django.core.management.base
import
BaseCommand
from
django.conf
import
settings
from
edxmako
import
lookup_template
from
django.core.mail
import
send_mass_mail
import
sys
import
datetime
def
chunks
(
l
,
n
):
""" Yield successive n-sized chunks from l.
"""
for
i
in
xrange
(
0
,
len
(
l
),
n
):
yield
l
[
i
:
i
+
n
]
class
Command
(
BaseCommand
):
help
=
\
'''Sends an e-mail to all users in a text file.
E.g.
manage.py userlist.txt message logfile.txt rate
userlist.txt -- list of all users
message -- prefix for template with message
logfile.txt -- where to log progress
rate -- messages per second
'''
log_file
=
None
def
hard_log
(
self
,
text
):
self
.
log_file
.
write
(
datetime
.
datetime
.
utcnow
()
.
isoformat
()
+
' -- '
+
text
+
'
\n
'
)
def
handle
(
self
,
*
args
,
**
options
):
(
user_file
,
message_base
,
logfilename
,
ratestr
)
=
args
users
=
[
u
.
strip
()
for
u
in
open
(
user_file
)
.
readlines
()]
message
=
lookup_template
(
'main'
,
'emails/'
+
message_base
+
"_body.txt"
)
.
render
()
subject
=
lookup_template
(
'main'
,
'emails/'
+
message_base
+
"_subject.txt"
)
.
render
()
.
strip
()
rate
=
int
(
ratestr
)
self
.
log_file
=
open
(
logfilename
,
"a+"
,
buffering
=
0
)
i
=
0
for
users
in
chunks
(
users
,
rate
):
emails
=
[(
subject
,
message
,
settings
.
DEFAULT_FROM_EMAIL
,
[
u
])
for
u
in
users
]
self
.
hard_log
(
" "
.
join
(
users
))
send_mass_mail
(
emails
,
fail_silently
=
False
)
time
.
sleep
(
1
)
print
datetime
.
datetime
.
utcnow
()
.
isoformat
(),
i
i
=
i
+
len
(
users
)
# Emergency interruptor
if
os
.
path
.
exists
(
"/tmp/stopemails.txt"
):
self
.
log_file
.
close
()
sys
.
exit
(
-
1
)
self
.
log_file
.
close
()
common/djangoapps/student/tests/emails/test_body.txt
deleted
100644 → 0
View file @
86fd303f
Test body.
common/djangoapps/student/tests/emails/test_subject.txt
deleted
100644 → 0
View file @
86fd303f
Test subject.
common/djangoapps/student/tests/test_massemail.py
deleted
100644 → 0
View file @
86fd303f
"""
Test `massemail` and `massemailtxt` commands.
"""
import
mock
import
pkg_resources
from
django.core
import
mail
from
django.test
import
TestCase
from
edxmako
import
add_lookup
from
..management.commands
import
massemail
from
..management.commands
import
massemailtxt
class
TestMassEmailCommands
(
TestCase
):
"""
Test `massemail` and `massemailtxt` commands.
"""
@mock.patch
(
'edxmako.LOOKUP'
,
{})
def
test_massemailtxt
(
self
):
"""
Test the `massemailtext` command.
"""
add_lookup
(
'main'
,
''
,
package
=
__name__
)
userfile
=
pkg_resources
.
resource_filename
(
__name__
,
'test_massemail_users.txt'
)
command
=
massemailtxt
.
Command
()
command
.
handle
(
userfile
,
'test'
,
'/dev/null'
,
10
)
self
.
assertEqual
(
len
(
mail
.
outbox
),
2
)
self
.
assertEqual
(
mail
.
outbox
[
0
]
.
to
,
[
"Fred"
])
self
.
assertEqual
(
mail
.
outbox
[
0
]
.
subject
,
"Test subject."
)
self
.
assertEqual
(
mail
.
outbox
[
0
]
.
body
.
strip
(),
"Test body."
)
self
.
assertEqual
(
mail
.
outbox
[
1
]
.
to
,
[
"Barney"
])
self
.
assertEqual
(
mail
.
outbox
[
1
]
.
subject
,
"Test subject."
)
self
.
assertEqual
(
mail
.
outbox
[
1
]
.
body
.
strip
(),
"Test body."
)
@mock.patch
(
'edxmako.LOOKUP'
,
{})
@mock.patch
(
'student.management.commands.massemail.User'
)
def
test_massemail
(
self
,
usercls
):
"""
Test the `massemail` command.
"""
add_lookup
(
'main'
,
''
,
package
=
__name__
)
fred
=
mock
.
Mock
()
barney
=
mock
.
Mock
()
usercls
.
objects
.
all
.
return_value
=
[
fred
,
barney
]
command
=
massemail
.
Command
()
command
.
handle
(
'test'
)
fred
.
email_user
.
assert_called_once_with
(
'Test subject.'
,
'Test body.
\n
'
)
barney
.
email_user
.
assert_called_once_with
(
'Test subject.'
,
'Test body.
\n
'
)
common/djangoapps/student/tests/test_massemail_users.txt
deleted
100644 → 0
View file @
86fd303f
Fred
Barney
lms/templates/emails/welcome_body.txt
deleted
100644 → 0
View file @
86fd303f
<%namespace file="../main.html" import="stanford_theme_enabled" />
## TODO: fix ugly hack
% if stanford_theme_enabled():
${settings.PLATFORM_NAME} Courses has launched! To log in, visit:
% else:
${settings.PLATFORM_NAME} has launched! To log in, visit:
% endif
% if is_secure:
https://${settings.SITE_NAME}
% else:
http://${settings.SITE_NAME}
% endif
A login button will be at the top right-hand corner of the window.
Please make sure you're using the latest version of Google Chrome or
Firefox. If you've forgotten your password, the log-in form has a
place to reset it.
Thanks for joining us for the ride!
## TODO: fix ugly hack
% if stanford_theme_enabled():
The ${settings.PLATFORM_NAME} Courses team
% else:
The ${settings.PLATFORM_NAME} team
% endif
(Please note that this e-mail address does not receive e-mails --
if you need assistance, please use the help section of the web
site)
lms/templates/emails/welcome_subject.txt
deleted
100644 → 0
View file @
86fd303f
<%namespace file="../main.html" import="stanford_theme_enabled" />
## TODO: fix ugly hack
% if stanford_theme_enabled():
Welcome to ${settings.PLATFORM_NAME} Courses!
% else:
Welcome to ${settings.PLATFORM_NAME}!
% endif
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