1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-09 02:42:47 +00:00

Add timestamp to user_notification

This commit is contained in:
xiez
2012-07-04 14:25:25 +08:00
parent 62c8aba292
commit bef3039a75
2 changed files with 8 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
#!/usr/bin/python
# encoding: utf-8
from datetime import datetime
import string
from django.core.mail import send_mail
@@ -17,6 +18,7 @@ ${msg_url}
Seafile团队
'''
today = datetime.now()
subject = u'SeaCloud新消息'
url = 'http://localhost:8000/home/my/'
@@ -24,6 +26,9 @@ notifications = UserNotification.objects.all()
d = {}
for e in notifications:
if today.year != e.timestamp.year or today.month != e.timestamp.month or \
today.day != e.timestamp.day:
continue
if d.has_key(e.to_user):
d[e.to_user] += 1
else:
@@ -32,7 +37,7 @@ for e in notifications:
for k in d.keys():
to_user = k
cnt = d[k]
template = string.Template(email_template)
content = template.substitute(username=to_user, cnt=cnt, msg_url=url)
send_mail(subject, content, settings.DEFAULT_FROM_EMAIL, [to_user], \