예제 #1
0
 def test_comment_history_comment_pre_update_handler(self):
     """
     comment_pre_update_handler signal
     """
     comment = utils.create_comment(topic=self.topic)
     comment_pre_update.send(sender=comment.__class__, comment=comment)
     self.assertEqual(CommentHistory.objects.get(comment_fk=comment.pk).comment_html, comment.comment_html)
     self.assertEqual(len(CommentHistory.objects.filter(comment_fk=comment.pk)), 1)
     comment_pre_update.send(sender=comment.__class__, comment=comment)
     self.assertEqual(len(CommentHistory.objects.filter(comment_fk=comment.pk)), 1)
예제 #2
0
파일: comment.py 프로젝트: mdamien/Spirit
def comment_update(request, pk):
    comment = Comment.objects.for_update_or_404(pk, request.user)

    if request.method == 'POST':
        form = CommentForm(data=request.POST, instance=comment)

        if form.is_valid():
            comment_pre_update.send(sender=comment.__class__, comment=Comment.objects.get(pk=comment.pk))
            comment = form.save()
            comment_post_update.send(sender=comment.__class__, comment=comment)
            return redirect(request.POST.get('next', comment.get_absolute_url()))
    else:
        form = CommentForm(instance=comment)

    return render(request, 'spirit/comment/comment_update.html', {'form': form, })
예제 #3
0
def comment_update(request, pk):
    comment = Comment.objects.for_update_or_404(pk, request.user)

    if request.method == 'POST':
        form = CommentForm(data=request.POST, instance=comment)

        if form.is_valid():
            comment_pre_update.send(sender=comment.__class__,
                                    comment=Comment.objects.get(pk=comment.pk))
            comment = form.save()
            comment_post_update.send(sender=comment.__class__, comment=comment)
            return redirect(
                request.POST.get('next', comment.get_absolute_url()))
    else:
        form = CommentForm(instance=comment)

    return render(request, 'spirit/comment/comment_update.html', {
        'form': form,
    })