示例#1
0
文件: views.py 项目: byu-osl/bookout
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
示例#2
0
文件: views.py 项目: byu-osl/bookout
def setup_book_borrow_actions(lenderID, bookCopyID):
	borrower = current_user()
	lender = UserAccount.getuser(int(lenderID))
	bookCopy = BookCopy.get_by_id(int(bookCopyID))
	
	rtb1 = RequestToBorrow()
	rtb1.useraccount = lender.key
	rtb1.connection = borrower.key
	rtb1.book = bookCopy.key
	rtb1.put()
	
	wtb1 = WaitingToBorrow()
	wtb1.useraccount = borrower.key
	wtb1.connection = lender.key
	wtb1.book = bookCopy.key
	wtb1.put()
	return jsonify({"Message":"OK"})