Пример #1
0
 def test_topic_comment_moved_handler(self):
     """
     comment_moved_handler signal
     """
     comment = utils.create_comment(topic=self.topic)
     comment2 = utils.create_comment(topic=self.topic)
     Topic.objects.filter(pk=self.topic.pk).update(comment_count=10)
     comment_moved.send(sender=comment.__class__, comments=[comment, comment2], topic_from=self.topic)
     self.assertEqual(Topic.objects.get(pk=self.topic.pk).comment_count, 8)
Пример #2
0
 def test_topic_comment_moved_handler(self):
     """
     comment_moved_handler signal
     """
     comment = utils.create_comment(topic=self.topic)
     comment2 = utils.create_comment(topic=self.topic)
     Topic.objects.filter(pk=self.topic.pk).update(comment_count=10)
     comment_moved.send(sender=comment.__class__,
                        comments=[comment, comment2],
                        topic_from=self.topic)
     self.assertEqual(Topic.objects.get(pk=self.topic.pk).comment_count, 8)
Пример #3
0
def comment_move(request, topic_id):
    topic = get_object_or_404(Topic, pk=topic_id)
    form = CommentMoveForm(topic=topic, data=request.POST)

    if form.is_valid():
        comments = form.save()

        for comment in comments:
            comment_posted.send(sender=comment.__class__, comment=comment, mentions=None)

        comment_moved.send(sender=Comment, comments=comments, topic_from=topic)
    else:
        messages.error(request, render_form_errors(form))

    return redirect(request.POST.get('next', topic.get_absolute_url()))
Пример #4
0
def comment_move(request, topic_id):
    topic = get_object_or_404(Topic, pk=topic_id)
    form = CommentMoveForm(topic=topic, data=request.POST)

    if form.is_valid():
        comments = form.save()

        for comment in comments:
            comment_posted.send(sender=comment.__class__,
                                comment=comment,
                                mentions=None)

        comment_moved.send(sender=Comment, comments=comments, topic_from=topic)
    else:
        messages.error(request, render_form_errors(form))

    return redirect(request.POST.get('next', topic.get_absolute_url()))