Exemplo n.º 1
0
def patch_is_unapproved(request, thread, value):
    allow_approve_thread(request.user, thread)

    if value:
        raise PermissionDenied(_("Content approval can't be reversed."))

    moderation.approve_thread(request, thread)

    return {
        'is_unapproved': thread.is_unapproved,
        'has_unapproved_posts': thread.has_unapproved_posts,
    }
Exemplo n.º 2
0
    def real_dispatch(self, request, post):
        if not post.acl['can_approve']:
            raise PermissionDenied(_("You can't approve this post."))

        if post.id == post.thread.first_post_id:
            moderation.approve_thread(request.user, post.thread)
            messages.success(request, _("Thread has been approved."))
        else:
            moderation.approve_post(request.user, post)
            messages.success(request, _("Post has been approved."))

        post.thread.synchronize()
        post.thread.save()
        post.forum.synchronize()
        post.forum.save()
Exemplo n.º 3
0
    def real_dispatch(self, request, post):
        if not post.acl['can_approve']:
            raise PermissionDenied(_("You can't approve this post."))

        if post.id == post.thread.first_post_id:
            moderation.approve_thread(request.user, post.thread)
            messages.success(request, _("Thread has been approved."))
        else:
            moderation.approve_post(request.user, post)
            messages.success(request, _("Post has been approved."))

        post.thread.synchronize()
        post.thread.save()
        post.forum.synchronize()
        post.forum.save()
Exemplo n.º 4
0
    def action_approve(self, request, threads):
        changed_threads = 0
        for thread in threads:
            if moderation.approve_thread(request.user, thread):
                changed_threads += 1

        if changed_threads:
            message = ungettext('%(changed)d thread was approved.',
                                '%(changed)d threads were approved.',
                                changed_threads)
            messages.success(request, message % {'changed': changed_threads})
        else:
            message = ("No threads were approved.")
            messages.info(request, message)
Exemplo n.º 5
0
    def action_approve(self, request, threads):
        changed_threads = 0
        for thread in threads:
            if moderation.approve_thread(request.user, thread):
                changed_threads += 1

        if changed_threads:
            message = ungettext(
                '%(changed)d thread was approved.',
                '%(changed)d threads were approved.',
            changed_threads)
            messages.success(request, message % {'changed': changed_threads})
        else:
            message = _("No threads were approved.")
            messages.info(request, message)
Exemplo n.º 6
0
    def test_approve_thread(self):
        """approve_thread approves unapproved thread"""
        self.thread = testutils.post_thread(self.category, is_unapproved=True)

        self.assertTrue(self.thread.is_unapproved)
        self.assertTrue(self.thread.first_post.is_unapproved)
        self.assertTrue(moderation.approve_thread(self.request, self.thread))

        self.reload_thread()
        self.assertFalse(self.thread.is_unapproved)
        self.assertFalse(self.thread.first_post.is_unapproved)

        event = self.thread.last_post

        self.assertTrue(event.is_event)
        self.assertEqual(event.event_type, 'approved')
Exemplo n.º 7
0
    def test_approve_thread(self):
        """approve_thread approves unapproved thread"""
        thread = testutils.post_thread(self.category, is_unapproved=True)

        self.assertTrue(thread.is_unapproved)
        self.assertTrue(thread.first_post.is_unapproved)
        self.assertTrue(moderation.approve_thread(self.user, thread))

        self.reload_thread()
        self.assertFalse(thread.is_unapproved)
        self.assertFalse(thread.first_post.is_unapproved)
        self.assertTrue(thread.has_events)
        event = thread.event_set.last()

        self.assertIn("approved thread.", event.message)
        self.assertEqual(event.icon, "check")
Exemplo n.º 8
0
 def action_approve(self, request, thread):
     moderation.approve_thread(request.user, thread)
     messages.success(request, _("Thread was approved."))
Exemplo n.º 9
0
 def action_approve(self, request, thread):
     moderation.approve_thread(request.user, thread)
     messages.success(request, _("Thread was approved."))