Delete posts after a ban is created for them

After a user is banned for a post, that post now gets deleted. There's
no way to turn this off yet.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-06-23 21:49:04 -07:00
parent a5510d9552
commit 1e61522f7a
2 changed files with 9 additions and 1 deletions

View File

@@ -308,6 +308,14 @@ class Ban(BanCommon):
return f"Ban for {self.ip}" return f"Ban for {self.ip}"
@receiver(signals.post_save, sender=Ban)
def ban_created(sender, instance, created, **kwargs):
if created:
if instance.post_id:
post = Post.objects.get(id=instance.post_id)
post.delete()
class BanTemplate(models.Model): class BanTemplate(models.Model):
# The name of this template # The name of this template
name = models.CharField(max_length=100) name = models.CharField(max_length=100)

View File

@@ -51,6 +51,7 @@ function openBanWindow(e) {
root: document.body, root: document.body,
onclose: function(force) { onclose: function(force) {
window.top.banWindow = null; window.top.banWindow = null;
window.top.location.reload();
} }
}); });
} }
@@ -61,6 +62,5 @@ function onLoad(e) {
$(".ban_link").on("click", openBanWindow); $(".ban_link").on("click", openBanWindow);
$(window).on("load", onLoad); $(window).on("load", onLoad);
</script> </script>
{% endblock %} {% endblock %}