normal.py
31 lines
| 846 B
| text/x-python
|
PythonLexer
|
r951 | from boards import settings | ||
from boards.views.thread import ThreadView | ||||
|
r1042 | TEMPLATE_NORMAL = 'boards/thread_normal.html' | ||
|
r951 | |||
CONTEXT_OP = 'opening_post' | ||||
CONTEXT_BUMPLIMIT_PRG = 'bumplimit_progress' | ||||
CONTEXT_POSTS_LEFT = 'posts_left' | ||||
CONTEXT_BUMPABLE = 'bumpable' | ||||
class NormalThreadView(ThreadView): | ||||
def get_template(self): | ||||
return TEMPLATE_NORMAL | ||||
def get_data(self, thread): | ||||
params = dict() | ||||
bumpable = thread.can_bump() | ||||
params[CONTEXT_BUMPABLE] = bumpable | ||||
|
r1052 | max_posts = thread.max_posts | ||
|
r951 | if bumpable: | ||
|
r1052 | left_posts = max_posts - thread.get_reply_count() | ||
|
r951 | params[CONTEXT_POSTS_LEFT] = left_posts | ||
params[CONTEXT_BUMPLIMIT_PRG] = str( | ||||
|
r1052 | float(left_posts) / max_posts * 100) | ||
|
r951 | |||
params[CONTEXT_OP] = thread.get_opening_post() | ||||
return params | ||||