예제 #1
0
 def test_mail_notify_new_argument(self):
     hugo = create_user("hugo")
     hugo.email = "*****@*****.**"
     hugo.profile.wants_mail_notification = True
     hugo.save()
     max = create_user("max")
     max.email = "*****@*****.**"
     max.profile.wants_mail_notification = True
     max.save()
     berta = create_user("berta")
     berta.email = "*****@*****.**"
     berta.profile.wants_mail_notification = False
     berta.save()
     post = create_post('System Message', hugo)
     node = create_nodes_for_path('/foo.1', [hugo])
     create_vote(hugo, [node])
     create_vote(max, [node])
     create_vote(berta, [node])
     create_argument(node, 'n', 'Bla', 'Blubb', [hugo])
     notify_new_argument(node, post)
     self.assertEqual(len(mail.outbox), 1)
     m = mail.outbox[0]
     self.assertEqual(m.to, [])
     self.assertEqual(m.bcc, ['*****@*****.**', '*****@*****.**'])
     self.assertIn('System Message', m.body)
     self.assertGreater(len(m.subject), 0)
예제 #2
0
def post_new_argument_for_node_message(user, path, arg_type, arg_path):
    post = Post()
    post.location = backend.get_node_for_path(path)
    post.author = get_system_user()
    post.post_type = Post.ARGUMENT_CREATED
    post.save()
    post.mentions = [user]
    post.node_references = [backend.get_node_for_path(arg_path), post.location]
    post.render()

    # email notification
    notify_new_argument(post.location, post)
    return post
예제 #3
0
def post_new_argument_for_node_message(user, path, arg_type, arg_path):
    post = Post()
    post.location = backend.get_node_for_path(path)
    post.author = get_system_user()
    post.post_type = Post.ARGUMENT_CREATED
    post.save()
    post.mentions = [user]
    post.node_references = [backend.get_node_for_path(arg_path), post.location]
    post.render()

    # email notification
    notify_new_argument(post.location, post)
    return post