Пример #1
0
  def get(self):
	user_address = "*****@*****.**"

	if not mail.is_email_valid(user_address):
		# prompt user to enter a valid address
		#print 'error'
		pass

	else:
		if self.chk_login():
			CurrentUser = self.get_user_db()

		tarsusaItemCollection = tarsusaCore.get_dailyroutine(CurrentUser.key().id())
		tarsusaItem_DueToday = tarsusaCore.get_ItemsDueToday(CurrentUser.key().id())
		
		ItemsInMail = ''
		for eachItem in tarsusaItem_DueToday:
			ItemsInMail += "<li><a href=/item/" + eachItem['id'] + ">" + eachItem['name'] + "</a></li>"

		DueTodayTotal = len(tarsusaItemCollection) + len(tarsusaItem_DueToday)
			
		message = mail.EmailMessage()
		message.sender = "*****@*****.**"
		message.to = user_address
		message.subject = "CheckNerds每日提醒 - " + str(datetime.date.today()) + " - " + str(DueTodayTotal) + "项事项"


	
		template_values = {
				'PrefixCSSdir': "/",
				'UserNickName': "访客",
				'AnonymousVisitor': "Yes",

				
				'Today': str(datetime.date.today()),
				'EmailTitle': message.subject,
				'CountItemsDueToday': str(DueTodayTotal),  
				'ItemsDueToday':tarsusaItemCollection + tarsusaItem_DueToday,
 
			}
	
		path = os.path.join(os.path.dirname(__file__), 'pages/mail/dailybriefing.html')
		final_body = template.render(path, template_values)

		message.html = final_body  
		message.send()
Пример #2
0
	def test_tarsusaCore_getitemsdueToday(self):
		DueToday = tarsusaCore.get_ItemsDueToday(userid=1)