normal.py
37 lines
| 1.1 KiB
| text/x-python
|
PythonLexer
neko259
|
r1771 | from boards import settings | ||
neko259
|
r2004 | from boards.settings import SECTION_FORMS | ||
neko259
|
r951 | from boards.views.thread import ThreadView | ||
neko259
|
r1396 | from boards.views.mixins import FileUploadMixin | ||
neko259
|
r951 | |||
neko259
|
r1042 | TEMPLATE_NORMAL = 'boards/thread_normal.html' | ||
neko259
|
r951 | |||
CONTEXT_BUMPLIMIT_PRG = 'bumplimit_progress' | ||||
CONTEXT_POSTS_LEFT = 'posts_left' | ||||
CONTEXT_BUMPABLE = 'bumpable' | ||||
neko259
|
r1396 | PARAM_MAX_FILE_SIZE = 'max_file_size' | ||
neko259
|
r1771 | PARAM_MAX_FILES = 'max_files' | ||
neko259
|
r951 | |||
neko259
|
r1396 | class NormalThreadView(ThreadView, FileUploadMixin): | ||
neko259
|
r951 | |||
def get_template(self): | ||||
return TEMPLATE_NORMAL | ||||
neko259
|
r1180 | def get_mode(self): | ||
return 'normal' | ||||
neko259
|
r951 | def get_data(self, thread): | ||
params = dict() | ||||
bumpable = thread.can_bump() | ||||
params[CONTEXT_BUMPABLE] = bumpable | ||||
neko259
|
r1052 | max_posts = thread.max_posts | ||
neko259
|
r1055 | if bumpable and thread.has_post_limit(): | ||
neko259
|
r1052 | left_posts = max_posts - thread.get_reply_count() | ||
neko259
|
r951 | params[CONTEXT_POSTS_LEFT] = left_posts | ||
params[CONTEXT_BUMPLIMIT_PRG] = str( | ||||
neko259
|
r1052 | float(left_posts) / max_posts * 100) | ||
neko259
|
r1396 | params[PARAM_MAX_FILE_SIZE] = self.get_max_upload_size() | ||
neko259
|
r2004 | params[PARAM_MAX_FILES] = settings.get_int(SECTION_FORMS, 'MaxFileCount') | ||
neko259
|
r951 | |||
return params | ||||