Exemple #1
0
def book_due_reminders():
	count = 0
	"""find all the books due tomorrow and send reminder emails"""
	books = BookCopy.query(BookCopy.due_date==date.today() + timedelta(days=1)).fetch()
	for book in books:
		count += 1
		owner = UserAccount.query(UserAccount.key==book.owner).get()
		mail.send_mail(sender=owner.email,
			to=UserAccount.query(UserAccount.key==book.borrower).get().email,
			subject="Book Due Soon",
			body="""Hey, remember that book you borrowed on Bookout from me, '%s'? Please get it back to me by tomorrow.
			
Thanks!
%s"""%(Book.query(Book.key==book.book).get().title,owner.name))
	return "%s reminders were sent out" %count