Пример #1
0
def patch_is_protected(request, post, value):
    allow_protect_post(request.user, post)
    if value:
        moderation.protect_post(request.user, post)
    else:
        moderation.unprotect_post(request.user, post)
    return {'is_protected': post.is_protected}
    def test_protect_post(self):
        """protect_post protects post"""
        self.assertFalse(self.post.is_protected)
        self.assertTrue(moderation.protect_post(self.user, self.post))

        self.reload_post()
        self.assertTrue(self.post.is_protected)
Пример #3
0
    def test_protect_post(self):
        """protect_post protects post"""
        self.assertFalse(self.post.is_protected)
        self.assertTrue(moderation.protect_post(self.user, self.post))

        self.reload_post()
        self.assertTrue(self.post.is_protected)
Пример #4
0
    def action_protect(self, request, posts):
        changed_posts = 0
        for post in posts:
            if moderation.protect_post(request.user, post):
                changed_posts += 1

        if changed_posts:
            message = ungettext(
                '%(changed)d post was made protected.',
                '%(changed)d posts were made protected.',
            changed_posts)
            messages.success(request, message % {'changed': changed_posts})
        else:
            message = _("No posts were made protected.")
            messages.info(request, message)
 def test_protect_protected_post(self):
     """protect_post fails to protect protected post gracefully"""
     self.post.is_protected = True
     self.assertFalse(moderation.protect_post(self.user, self.post))
Пример #6
0
 def test_protect_protected_post(self):
     """protect_post fails to protect protected post gracefully"""
     self.post.is_protected = True
     self.assertFalse(moderation.protect_post(self.user, self.post))