-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
38 lines (32 loc) · 1.79 KB
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
import os
import sys
from django.core.management.base import NoArgsCommand, make_option
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "TritonValvesTraining.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
class Command(NoArgsCommand):
help = "Django Emailer"
option_list = NoArgsCommand.option_list + (
make_option('--verbose', action='store_true'),
)
def handle_noargs(self, **options):
import datetime
from django.core.mail import send_mail
from Users.userfunctions import ScheduleMessages
from django.template.loader import get_template
from django.template.context import Context
from django.core.mail.message import EmailMessage
t = get_template('emailTemplate.html')
today = datetime.datetime.today()
tomorrow = today + datetime.timedelta(1)
day_after = tomorrow + datetime.timedelta(1)
today_messages = ScheduleMessages(today.month,today.year).get_message_for_day(today.day)
tomorrow_messages = ScheduleMessages(tomorrow.month,tomorrow.year).get_message_for_day(tomorrow.day)
day_after_messages = ScheduleMessages(day_after.month,day_after.year).get_message_for_day(day_after.day)
#stri = "Tasks:- \n Today's:" + "\n" + today_messages + "\n" + "Tomorrow:" + "\n" + tomorrow_messages + " Day After: " + "\n" + day_after_messages
c = Context({'today':today , 'tomorrow':tomorrow , 'day_after':day_after})
msg = EmailMessage(subject = "Daily Notifications" , body = t.render(c), from_email ='arjun.krishna1994@gmail.com', to = ['arjun.krishna1994@gmail.com'])
msg.content_subtype = "html" # Main content is now text/html
msg.send()