##// END OF EJS Templates
Refactored thread views
neko259 -
r1185:ef257c39 default
parent child Browse files
Show More
@@ -3,7 +3,6 b' from boards.views.thread import ThreadVi'
3 3 TEMPLATE_GALLERY = 'boards/thread_gallery.html'
4 4
5 5 CONTEXT_POSTS = 'posts'
6 CONTEXT_OP = 'opening_post'
7 6
8 7
9 8 class GalleryThreadView(ThreadView):
@@ -16,7 +15,6 b' class GalleryThreadView(ThreadView):'
16 15
17 16 params[CONTEXT_POSTS] = thread.get_replies_with_images(
18 17 view_fields_only=True)
19 params[CONTEXT_OP] = thread.get_opening_post()
20 18
21 19 return params
22 20
@@ -1,9 +1,7 b''
1 from boards import settings
2 1 from boards.views.thread import ThreadView
3 2
4 3 TEMPLATE_NORMAL = 'boards/thread_normal.html'
5 4
6 CONTEXT_OP = 'opening_post'
7 5 CONTEXT_BUMPLIMIT_PRG = 'bumplimit_progress'
8 6 CONTEXT_POSTS_LEFT = 'posts_left'
9 7 CONTEXT_BUMPABLE = 'bumpable'
@@ -29,6 +27,4 b' class NormalThreadView(ThreadView):'
29 27 params[CONTEXT_BUMPLIMIT_PRG] = str(
30 28 float(left_posts) / max_posts * 100)
31 29
32 params[CONTEXT_OP] = thread.get_opening_post()
33
34 30 return params
@@ -22,6 +22,7 b" CONTEXT_WS_HOST = 'ws_host'"
22 22 CONTEXT_WS_PORT = 'ws_port'
23 23 CONTEXT_WS_TIME = 'ws_token_time'
24 24 CONTEXT_MODE = 'mode'
25 CONTEXT_OP = 'opening_post'
25 26
26 27 FORM_TITLE = 'title'
27 28 FORM_TEXT = 'text'
@@ -53,6 +54,7 b' class ThreadView(BaseBoardView, PostMixi'
53 54 params[CONTEXT_LASTUPDATE] = str(thread_to_show.last_edit_time)
54 55 params[CONTEXT_THREAD] = thread_to_show
55 56 params[CONTEXT_MODE] = self.get_mode()
57 params[CONTEXT_OP] = opening_post
56 58
57 59 if settings.get_bool('External', 'WebsocketsEnabled'):
58 60 token_time = format(timezone.now(), u'U')
@@ -118,19 +120,19 b' class ThreadView(BaseBoardView, PostMixi'
118 120 else:
119 121 return post
120 122
121 def get_data(self, thread):
123 def get_data(self, thread) -> dict:
122 124 """
123 125 Returns context params for the view.
124 126 """
125 127
126 pass
128 return dict()
127 129
128 def get_template(self):
130 def get_template(self) -> str:
129 131 """
130 132 Gets template to show the thread mode on.
131 133 """
132 134
133 135 pass
134 136
135 def get_mode(self):
137 def get_mode(self) -> str:
136 138 pass
@@ -1,27 +1,12 b''
1 from boards import settings
2 1 from boards.views.thread import ThreadView
3 2
4 3 TEMPLATE_TREE = 'boards/thread_tree.html'
5 4
6 CONTEXT_OP = 'opening_post'
7 CONTEXT_BUMPABLE = 'bumpable'
8
9 5
10 6 class TreeThreadView(ThreadView):
11 7
12 8 def get_template(self):
13 9 return TEMPLATE_TREE
14 10
15 def get_data(self, thread):
16 params = dict()
17
18 bumpable = thread.can_bump()
19 params[CONTEXT_BUMPABLE] = bumpable
20 max_posts = thread.max_posts
21
22 params[CONTEXT_OP] = thread.get_opening_post()
23
24 return params
25
26 11 def get_mode(self):
27 12 return 'tree'
General Comments 0
You need to be logged in to leave comments. Login now