def action_delete(self, request, thread): with atomic(): self.forum.lock() moderation.delete_thread(request.user, thread) self.forum.synchronize() self.forum.save() message = _('Thread "%(thread)s" was deleted.') messages.success(request, message % {'thread': thread.title}) return redirect(self.forum.get_absolute_url())
def action_delete(self, request, threads): changed_threads = 0 for thread in threads: if moderation.delete_thread(request.user, thread): changed_threads += 1 if changed_threads: with atomic(): self.forum.synchronize() self.forum.save() message = ungettext('%(changed)d thread was deleted.', '%(changed)d threads were deleted.', changed_threads) messages.success(request, message % {'changed': changed_threads}) else: message = _("No threads were deleted.") messages.info(request, message)
def action_delete(self, request, threads): changed_threads = 0 for thread in threads: if moderation.delete_thread(request.user, thread): changed_threads += 1 if changed_threads: with atomic(): self.forum.synchronize() self.forum.save() message = ungettext( '%(changed)d thread was deleted.', '%(changed)d threads were deleted.', changed_threads) messages.success(request, message % {'changed': changed_threads}) else: message = _("No threads were deleted.") messages.info(request, message)
def test_delete_thread(self): """delete_thread deletes thread""" self.assertTrue(moderation.delete_thread(self.request, self.thread)) with self.assertRaises(Thread.DoesNotExist): self.reload_thread()
def test_delete_thread(self): """delete_thread deletes thread""" self.assertTrue(moderation.delete_thread(self.user, self.thread)) with self.assertRaises(Thread.DoesNotExist): self.reload_thread()
def delete_thread(request, thread): allow_delete_thread(request.user, thread) moderation.delete_thread(request.user, thread) return Response({})