diff --git a/board/forms.py b/board/forms.py index 1dc56b4..54e94bc 100644 --- a/board/forms.py +++ b/board/forms.py @@ -29,7 +29,7 @@ class ReplyForm(PostForm): class Meta: model = Post - fields = ["name", "text", "image"] + fields = ["name", "text", "bump", "image"] def __init__(self, *args, op, reply, **kwargs): super(ReplyForm, self).__init__(*args, **kwargs) diff --git a/board/models.py b/board/models.py index db589f9..c3286cf 100644 --- a/board/models.py +++ b/board/models.py @@ -47,6 +47,9 @@ class Board(models.Model): # The amount of time that users from the same IP address are allowed to make # consecutive posts post_cooldown = models.DurationField(default=timedelta(seconds=60)) + # Auto-sink threshhold. This is the number of replies that a thread can have + # before it stops being bumped. + autosink = models.IntegerField(default=300) @property def threads(self): @@ -89,6 +92,9 @@ class Post(models.Model): width_field="image_width", height_field="image_height", ) + # Bump - if this post is an OP, determines whether the OP can be bumped. If + # this post is not an OP, determines whether the thread SHOULD be bumped. + bump = models.BooleanField(default=True) # Thumbnail thumbnail = models.ImageField(upload_to=thumbs_upload, editable=False, null=True) # Original image name @@ -172,8 +178,13 @@ def post_created(sender, instance, created, **kwargs): if created: if instance.op: # Update the bump - instance.op.last_bump = timezone.now() - instance.op.save() + if ( + instance.bump + and instance.op.bump + and instance.op.replies.count() < instance.board.autosink + ): + instance.op.last_bump = timezone.now() + instance.op.save() else: # Prune threads for the board instance.board.prune_threads()