示例#1
0
文件: forms.py 项目: ixth/blombum
 def save(self, approved=True, user_is_new=False):
     node = CommentNode(user=self.user, object=self.parent, body=self.cleaned_data['body'], approved=approved)
     node.save()
     if appcheck.watchlist and self.cleaned_data.get('subscribe'):
         from watchlist.models import Subscription
         Subscription.objects.subscribe(self.user, node.object)
     return node, user_is_new
示例#2
0
文件: forms.py 项目: exezaid/Dpress
 def save(self, approved=True, user_is_new=False):
     node = CommentNode(user=self.user,
                        object=self.parent,
                        body=self.cleaned_data['body'],
                        approved=approved)
     node.save()
     return node, user_is_new
示例#3
0
文件: tests.py 项目: ixth/blombum
 def testDeleteComments(self):
     c = CommentNode(approved=False, body="just test", user=self.user,
                     object=self.p1)
     c.save()
     self.assertEquals(CommentNode.all_objects.count(), 1)
     self.p1.delete()
     self.assertEquals(CommentNode.all_objects.count(), 0)
示例#4
0
def _save_comment(comment_id, new_post, old_post):
    comment = Comment.objects.get(pk=comment_id)
    if not comment.post == old_post:
        raise ValueError("this comment does not belong to this post")
    try:
        user = User.objects.get(email__iexact=comment.author_email)
    except User.DoesNotExist:
        user = ActionRecord.objects.create_user(name=comment.author,
                                                email=comment.author_email,
                                                password=uuid.uuid4().hex[:10],
                                                send_email=False,
                                                site=comment.author_url)
    new = CommentNode(
        user=user,
        pub_date=comment.date,
        body_html=comment.content,
        approved=True,
        object=new_post,
    )
    new.save()
    return new