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:
@@ -29,7 +29,7 @@ class ReplyForm(PostForm):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Post
|
model = Post
|
||||||
fields = ["name", "text", "image"]
|
fields = ["name", "text", "bump", "image"]
|
||||||
|
|
||||||
def __init__(self, *args, op, reply, **kwargs):
|
def __init__(self, *args, op, reply, **kwargs):
|
||||||
super(ReplyForm, self).__init__(*args, **kwargs)
|
super(ReplyForm, self).__init__(*args, **kwargs)
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ class Board(models.Model):
|
|||||||
# The amount of time that users from the same IP address are allowed to make
|
# The amount of time that users from the same IP address are allowed to make
|
||||||
# consecutive posts
|
# consecutive posts
|
||||||
post_cooldown = models.DurationField(default=timedelta(seconds=60))
|
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
|
@property
|
||||||
def threads(self):
|
def threads(self):
|
||||||
@@ -89,6 +92,9 @@ class Post(models.Model):
|
|||||||
width_field="image_width",
|
width_field="image_width",
|
||||||
height_field="image_height",
|
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
|
||||||
thumbnail = models.ImageField(upload_to=thumbs_upload, editable=False, null=True)
|
thumbnail = models.ImageField(upload_to=thumbs_upload, editable=False, null=True)
|
||||||
# Original image name
|
# Original image name
|
||||||
@@ -172,6 +178,11 @@ def post_created(sender, instance, created, **kwargs):
|
|||||||
if created:
|
if created:
|
||||||
if instance.op:
|
if instance.op:
|
||||||
# Update the bump
|
# Update the bump
|
||||||
|
if (
|
||||||
|
instance.bump
|
||||||
|
and instance.op.bump
|
||||||
|
and instance.op.replies.count() < instance.board.autosink
|
||||||
|
):
|
||||||
instance.op.last_bump = timezone.now()
|
instance.op.last_bump = timezone.now()
|
||||||
instance.op.save()
|
instance.op.save()
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user