Ejemplo n.º 1
0
 def test_flag_create(self):
     """
     create flag
     """
     form_data = {'reason': '0', 'body': 'spam comment foo'}
     form = FlagForm(data=form_data)
     form.comment = self.comment
     form.user = self.user
     self.assertEqual(form.is_valid(), True)
     form.save()
     self.assertEqual(len(CommentFlag.objects.all()), 1)
 def test_flag_create(self):
     """
     create flag
     """
     form_data = {'reason': '0', 'body': 'spam comment foo'}
     form = FlagForm(data=form_data)
     form.comment = self.comment
     form.user = self.user
     self.assertEqual(form.is_valid(), True)
     form.save()
     self.assertEqual(len(CommentFlag.objects.all()), 1)
Ejemplo n.º 3
0
def flag_create(request, comment_id):
    comment = get_object_or_404(Comment, pk=comment_id)

    if request.method == 'POST':
        form = FlagForm(user=request.user, comment=comment, data=request.POST)

        if form.is_valid():
            form.save()
            return redirect(request.POST.get('next', comment.get_absolute_url()))
    else:
        form = FlagForm()

    return render(request, 'foro/comment_flag/flag_create.html', {'form': form, 'comment': comment})