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}"
@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):
# The name of this template
name = models.CharField(max_length=100)