mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 10:50:24 +00:00
Add timestamp to user_notification
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import datetime
|
||||
from django.db import models
|
||||
from django.forms import ModelForm, Textarea
|
||||
|
||||
@@ -9,6 +10,7 @@ class UserNotification(models.Model):
|
||||
to_user = models.EmailField(db_index=True, max_length=255)
|
||||
msg_type = models.CharField(db_index=True, max_length=30)
|
||||
detail = models.TextField()
|
||||
timestamp = models.DateTimeField(default=datetime.datetime.now)
|
||||
|
||||
class NotificationForm(ModelForm):
|
||||
"""
|
||||
|
@@ -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], \
|
||||
|
Reference in New Issue
Block a user