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