# HG changeset patch # User neko259 # Date 2015-03-26 09:25:31 # Node ID a66b11af2162cf2b0f74d741e82fccec22973cd6 # Parent 3388bcbc608fc5ea21e1afe9900f993336741069 Save bump limit separately for every thread diff --git a/boards/migrations/0012_thread_max_posts.py b/boards/migrations/0012_thread_max_posts.py new file mode 100644 --- /dev/null +++ b/boards/migrations/0012_thread_max_posts.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('boards', '0011_notification'), + ] + + operations = [ + migrations.AddField( + model_name='thread', + name='max_posts', + field=models.IntegerField(default=10), + preserve_default=True, + ), + ] diff --git a/boards/models/thread.py b/boards/models/thread.py --- a/boards/models/thread.py +++ b/boards/models/thread.py @@ -57,6 +57,7 @@ class Thread(models.Model): last_edit_time = models.DateTimeField() archived = models.BooleanField(default=False) bumpable = models.BooleanField(default=True) + max_posts = models.IntegerField(default=settings.MAX_POSTS_PER_THREAD) def get_tags(self): """ @@ -78,7 +79,7 @@ class Thread(models.Model): logger.info('Bumped thread %d' % self.id) def update_bump_status(self): - if self.get_reply_count() >= settings.MAX_POSTS_PER_THREAD: + if self.get_reply_count() >= self.max_posts: self.bumpable = False self.update_posts_time() diff --git a/boards/settings.py b/boards/settings.py --- a/boards/settings.py +++ b/boards/settings.py @@ -1,3 +1,4 @@ from boards.default_settings import * -# Site-specific settings go here \ No newline at end of file +# Site-specific settings go here +MAX_POSTS_PER_THREAD = 12 diff --git a/boards/templates/boards/thread.html b/boards/templates/boards/thread.html --- a/boards/templates/boards/thread.html +++ b/boards/templates/boards/thread.html @@ -25,7 +25,7 @@ {% endblock %} {% cache 600 thread_meta thread.last_edit_time moderator LANGUAGE_CODE %} - {{ thread.get_reply_count }}/{{ max_replies }} {% trans 'messages' %}, + {{ thread.get_reply_count }}/{{ thread.max_posts }} {% trans 'messages' %}, {{ thread.get_images_count }} {% trans 'images' %}. {% trans 'Last update: ' %} [RSS] diff --git a/boards/views/thread/normal.py b/boards/views/thread/normal.py --- a/boards/views/thread/normal.py +++ b/boards/views/thread/normal.py @@ -19,12 +19,12 @@ class NormalThreadView(ThreadView): bumpable = thread.can_bump() params[CONTEXT_BUMPABLE] = bumpable + max_posts = thread.max_posts if bumpable: - left_posts = settings.MAX_POSTS_PER_THREAD \ - - thread.get_reply_count() + left_posts = max_posts - thread.get_reply_count() params[CONTEXT_POSTS_LEFT] = left_posts params[CONTEXT_BUMPLIMIT_PRG] = str( - float(left_posts) / settings.MAX_POSTS_PER_THREAD * 100) + float(left_posts) / max_posts * 100) params[CONTEXT_OP] = thread.get_opening_post() diff --git a/boards/views/thread/thread.py b/boards/views/thread/thread.py --- a/boards/views/thread/thread.py +++ b/boards/views/thread/thread.py @@ -12,7 +12,6 @@ import neboard CONTEXT_LASTUPDATE = "last_update" -CONTEXT_MAX_REPLIES = 'max_replies' CONTEXT_THREAD = 'thread' CONTEXT_WS_TOKEN = 'ws_token' CONTEXT_WS_PROJECT = 'ws_project' @@ -47,7 +46,6 @@ class ThreadView(BaseBoardView, PostMixi params[CONTEXT_LASTUPDATE] = str(utils.datetime_to_epoch( thread_to_show.last_edit_time)) params[CONTEXT_THREAD] = thread_to_show - params[CONTEXT_MAX_REPLIES] = settings.MAX_POSTS_PER_THREAD if settings.WEBSOCKETS_ENABLED: params[CONTEXT_WS_TOKEN] = utils.get_websocket_token(