diff --git a/board/models.py b/board/models.py index ec8c492..9c0be28 100644 --- a/board/models.py +++ b/board/models.py @@ -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) diff --git a/board/templates/admin/board/reportrecord/change_list.html b/board/templates/admin/board/reportrecord/change_list.html index 10ca523..1eec199 100644 --- a/board/templates/admin/board/reportrecord/change_list.html +++ b/board/templates/admin/board/reportrecord/change_list.html @@ -51,6 +51,7 @@ function openBanWindow(e) { root: document.body, onclose: function(force) { window.top.banWindow = null; + window.top.location.reload(); } }); } @@ -61,6 +62,5 @@ function onLoad(e) { $(".ban_link").on("click", openBanWindow); $(window).on("load", onLoad); - {% endblock %} \ No newline at end of file