-
Notifications
You must be signed in to change notification settings - Fork 0
/
cronjob.py
34 lines (25 loc) · 1.02 KB
/
cronjob.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
from lunardate import LunarDate
from messagingjob import MessagingJob
import webapp2
import datetime
import lunarcalendarportal
from google.appengine.api import mail
SENDER="Lunar Calendar Reminder <jonathan@chanfamily.org>"
EMAIL_BODY="""Dear %s,
We are writing you to remind you of the following event that you set on the lunar calendar reminder:
%s
Your next reminder will be sent: %s
You may enable/disable this event by visiting the webpage. Thank you for using this service!
Lunar Calendar Reminder
"""
class DailyEmail(webapp2.RequestHandler):
def get(self):
today_ld=LunarDate.today()
q1=MessagingJob.query(MessagingJob.lunar_month == today_ld.month,
MessagingJob.lunar_day == today_ld.day)
for job in q1.iter():
mail.send_mail(sender=SENDER,
to=job.owner.email(),
subject="Lunar Calendar Reminder - "+job.note,
body= EMAIL_BODY % (job.owner.nickname(),
job.note, job.getNextRun()))