##// END OF EJS Templates
Unify thread and post creation into one method inside post manager, that can be called from almost anywhere (one step closer to ajax thread creation)
Unify thread and post creation into one method inside post manager, that can be called from almost anywhere (one step closer to ajax thread creation)

File last commit:

r1771:11a13b7c default
r1997:be673d04 default
Show More
normal.py
36 lines | 1.1 KiB | text/x-python | PythonLexer
from boards import settings
from boards.views.thread import ThreadView
from boards.views.mixins import FileUploadMixin
TEMPLATE_NORMAL = 'boards/thread_normal.html'
CONTEXT_BUMPLIMIT_PRG = 'bumplimit_progress'
CONTEXT_POSTS_LEFT = 'posts_left'
CONTEXT_BUMPABLE = 'bumpable'
PARAM_MAX_FILE_SIZE = 'max_file_size'
PARAM_MAX_FILES = 'max_files'
class NormalThreadView(ThreadView, FileUploadMixin):
def get_template(self):
return TEMPLATE_NORMAL
def get_mode(self):
return 'normal'
def get_data(self, thread):
params = dict()
bumpable = thread.can_bump()
params[CONTEXT_BUMPABLE] = bumpable
max_posts = thread.max_posts
if bumpable and thread.has_post_limit():
left_posts = max_posts - thread.get_reply_count()
params[CONTEXT_POSTS_LEFT] = left_posts
params[CONTEXT_BUMPLIMIT_PRG] = str(
float(left_posts) / max_posts * 100)
params[PARAM_MAX_FILE_SIZE] = self.get_max_upload_size()
params[PARAM_MAX_FILES] = settings.get_int('Forms', 'MaxFileCount')
return params