示例#1
0
    def test_flag(self):
        """
        flag
        """
        comment = utils.create_comment(topic=self.topic)
        comment_flag = CommentFlag.objects.create(comment=comment)

        form_data = {"is_closed": True, }
        form = CommentFlagForm(user=self.user, data=form_data, instance=comment_flag)
        self.assertEqual(form.is_valid(), True)
        self.assertEqual(repr(form.save().moderator), repr(self.user))
示例#2
0
def flag_detail(request, pk):
    flag = get_object_or_404(CommentFlag, pk=pk)

    if request.method == 'POST':
        form = CommentFlagForm(user=request.user, data=request.POST, instance=flag)

        if form.is_valid():
            form.save()
            messages.info(request, _("The flag has been moderated!"))
            return redirect(reverse("spirit:admin-flag"))
    else:
        form = CommentFlagForm(instance=flag)

    flags = Flag.objects.filter(comment=flag.comment)
    return render(request, 'spirit/admin/comment_flag/flag_detail.html', {'flag': flag,
                                                                          'flags': flags,
                                                                          'form': form})
示例#3
0
def flag_detail(request, pk):
    flag = get_object_or_404(CommentFlag, pk=pk)

    if request.method == 'POST':
        form = CommentFlagForm(user=request.user,
                               data=request.POST,
                               instance=flag)

        if form.is_valid():
            form.save()
            messages.info(request, _("The flag has been moderated!"))
            return redirect(reverse("spirit:admin-flag"))
    else:
        form = CommentFlagForm(instance=flag)

    flags = Flag.objects.filter(comment=flag.comment)
    return render(request, 'spirit/admin/comment_flag/flag_detail.html', {
        'flag': flag,
        'flags': flags,
        'form': form
    })