def post_create_notification(post): "Generates notifications to all users related with this post. Invoked only on the creation of the post" root = post.root or post authors = set( [ root.author ] ) for child in Post.objects.filter(root=root): authors.add(child.author) text = notegen.post_action(user=post.author, post=post) for target in authors: unread = (target != post.author) # the unread flag will be off for the post author send_note(sender=post.author, target=target, content=text, type=NOTE_USER, unread=unread, date=post.creation_date, url=post.get_absolute_url() )
def post_create_notification(post): "Generates notifications to all users related with this post. Invoked only on the creation of the post" root = post.root or post authors = set( [ root.author ] ) # add users that want to just follow the post for row in Watcher.objects.filter(pk=post.id, type=Watcher.NOTE).select_related('user'): authors.add(row.user) for child in Post.objects.filter(root=root).select_related('author'): authors.add(child.author) text = notegen.post_action(user=post.author, post=post) # generate emails for people that want to follow a post via email for row in Watcher.objects.filter(pk=post.id, type=Watcher.EMAIL).select_related('user'): tasks.send_test_email() for target in authors: unread = (target != post.author) # the unread flag will be off for the post author send_note(sender=post.author, target=target, content=text, type=NOTE_USER, unread=unread, date=post.creation_date, url=post.get_absolute_url() )