Add sage-like functionality a la 4chan
When reply to a post, you can uncheck "bump" and it will not bump the thread to the top of the board. This is useful for the OP, too, because it allows for "permasage" functionality which is useful for moderators. Finally, there is also "autosink" functionality. After a per-board threshhold of posts, a thread will stop bumping. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user