-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For #4
- Loading branch information
Showing
6 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from django.core import mail | ||
from django_extensions.management.jobs import DailyJob | ||
|
||
from journal.accounts.models import Account | ||
|
||
|
||
class Job(DailyJob): | ||
help = "Sent mail to active accounts" | ||
|
||
def execute(self): | ||
accounts = Account.objects.active().select_related("user") | ||
for account in accounts: | ||
mail.send_mail( | ||
subject="Replace this subject", | ||
message="Replace this message", | ||
html_message="Replace this HTML message", | ||
from_email="who is this from email", | ||
recipient_list=[account.user.email], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from journal.accounts.tests.factories import UserFactory | ||
from journal.entries.jobs.send_mail import Job as SendMailJob | ||
|
||
|
||
class TestSendMailJob: | ||
def test_send_email(self, mailoutbox): | ||
"""An active account receives an email prompt.""" | ||
user = UserFactory() | ||
job = SendMailJob() | ||
|
||
job.execute() | ||
|
||
assert len(mailoutbox) == 1 | ||
mail = mailoutbox[0] | ||
assert mail.to == [user.email] | ||
# TODO: assert subject | ||
# TODO: assert message | ||
# TODO: assert html_message | ||
# TODO: assert from_email |