##// END OF EJS Templates
Save bump limit separately for every thread
neko259 -
r1052:a66b11af default
parent child Browse files
Show More
@@ -0,0 +1,20 b''
1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
3
4 from django.db import models, migrations
5
6
7 class Migration(migrations.Migration):
8
9 dependencies = [
10 ('boards', '0011_notification'),
11 ]
12
13 operations = [
14 migrations.AddField(
15 model_name='thread',
16 name='max_posts',
17 field=models.IntegerField(default=10),
18 preserve_default=True,
19 ),
20 ]
@@ -57,6 +57,7 b' class Thread(models.Model):'
57 last_edit_time = models.DateTimeField()
57 last_edit_time = models.DateTimeField()
58 archived = models.BooleanField(default=False)
58 archived = models.BooleanField(default=False)
59 bumpable = models.BooleanField(default=True)
59 bumpable = models.BooleanField(default=True)
60 max_posts = models.IntegerField(default=settings.MAX_POSTS_PER_THREAD)
60
61
61 def get_tags(self):
62 def get_tags(self):
62 """
63 """
@@ -78,7 +79,7 b' class Thread(models.Model):'
78 logger.info('Bumped thread %d' % self.id)
79 logger.info('Bumped thread %d' % self.id)
79
80
80 def update_bump_status(self):
81 def update_bump_status(self):
81 if self.get_reply_count() >= settings.MAX_POSTS_PER_THREAD:
82 if self.get_reply_count() >= self.max_posts:
82 self.bumpable = False
83 self.bumpable = False
83 self.update_posts_time()
84 self.update_posts_time()
84
85
@@ -1,3 +1,4 b''
1 from boards.default_settings import *
1 from boards.default_settings import *
2
2
3 # Site-specific settings go here No newline at end of file
3 # Site-specific settings go here
4 MAX_POSTS_PER_THREAD = 12
@@ -25,7 +25,7 b''
25 {% endblock %}
25 {% endblock %}
26
26
27 {% cache 600 thread_meta thread.last_edit_time moderator LANGUAGE_CODE %}
27 {% cache 600 thread_meta thread.last_edit_time moderator LANGUAGE_CODE %}
28 <span id="reply-count">{{ thread.get_reply_count }}</span>/{{ max_replies }} {% trans 'messages' %},
28 <span id="reply-count">{{ thread.get_reply_count }}</span>/{{ thread.max_posts }} {% trans 'messages' %},
29 <span id="image-count">{{ thread.get_images_count }}</span> {% trans 'images' %}.
29 <span id="image-count">{{ thread.get_images_count }}</span> {% trans 'images' %}.
30 {% trans 'Last update: ' %}<span id="last-update"><time datetime="{{ thread.last_edit_time|date:'c' }}">{{ thread.last_edit_time|date:'r' }}</time></span>
30 {% trans 'Last update: ' %}<span id="last-update"><time datetime="{{ thread.last_edit_time|date:'c' }}">{{ thread.last_edit_time|date:'r' }}</time></span>
31 [<a href="rss/">RSS</a>]
31 [<a href="rss/">RSS</a>]
@@ -19,12 +19,12 b' class NormalThreadView(ThreadView):'
19
19
20 bumpable = thread.can_bump()
20 bumpable = thread.can_bump()
21 params[CONTEXT_BUMPABLE] = bumpable
21 params[CONTEXT_BUMPABLE] = bumpable
22 max_posts = thread.max_posts
22 if bumpable:
23 if bumpable:
23 left_posts = settings.MAX_POSTS_PER_THREAD \
24 left_posts = max_posts - thread.get_reply_count()
24 - thread.get_reply_count()
25 params[CONTEXT_POSTS_LEFT] = left_posts
25 params[CONTEXT_POSTS_LEFT] = left_posts
26 params[CONTEXT_BUMPLIMIT_PRG] = str(
26 params[CONTEXT_BUMPLIMIT_PRG] = str(
27 float(left_posts) / settings.MAX_POSTS_PER_THREAD * 100)
27 float(left_posts) / max_posts * 100)
28
28
29 params[CONTEXT_OP] = thread.get_opening_post()
29 params[CONTEXT_OP] = thread.get_opening_post()
30
30
@@ -12,7 +12,6 b' import neboard'
12
12
13
13
14 CONTEXT_LASTUPDATE = "last_update"
14 CONTEXT_LASTUPDATE = "last_update"
15 CONTEXT_MAX_REPLIES = 'max_replies'
16 CONTEXT_THREAD = 'thread'
15 CONTEXT_THREAD = 'thread'
17 CONTEXT_WS_TOKEN = 'ws_token'
16 CONTEXT_WS_TOKEN = 'ws_token'
18 CONTEXT_WS_PROJECT = 'ws_project'
17 CONTEXT_WS_PROJECT = 'ws_project'
@@ -47,7 +46,6 b' class ThreadView(BaseBoardView, PostMixi'
47 params[CONTEXT_LASTUPDATE] = str(utils.datetime_to_epoch(
46 params[CONTEXT_LASTUPDATE] = str(utils.datetime_to_epoch(
48 thread_to_show.last_edit_time))
47 thread_to_show.last_edit_time))
49 params[CONTEXT_THREAD] = thread_to_show
48 params[CONTEXT_THREAD] = thread_to_show
50 params[CONTEXT_MAX_REPLIES] = settings.MAX_POSTS_PER_THREAD
51
49
52 if settings.WEBSOCKETS_ENABLED:
50 if settings.WEBSOCKETS_ENABLED:
53 params[CONTEXT_WS_TOKEN] = utils.get_websocket_token(
51 params[CONTEXT_WS_TOKEN] = utils.get_websocket_token(
General Comments 0
You need to be logged in to leave comments. Login now