Show More
@@ -39,7 +39,7 b" PARAMETER_TRUNCATED = 'truncated'" | |||||
39 | PARAMETER_TAG = 'tag' |
|
39 | PARAMETER_TAG = 'tag' | |
40 | PARAMETER_OFFSET = 'offset' |
|
40 | PARAMETER_OFFSET = 'offset' | |
41 | PARAMETER_DIFF_TYPE = 'type' |
|
41 | PARAMETER_DIFF_TYPE = 'type' | |
42 | PARAMETER_BUMPABLE = 'bumpable' |
|
42 | PARAMETER_CSS_CLASS = 'css_class' | |
43 | PARAMETER_THREAD = 'thread' |
|
43 | PARAMETER_THREAD = 'thread' | |
44 | PARAMETER_IS_OPENING = 'is_opening' |
|
44 | PARAMETER_IS_OPENING = 'is_opening' | |
45 | PARAMETER_MODERATOR = 'moderator' |
|
45 | PARAMETER_MODERATOR = 'moderator' | |
@@ -230,7 +230,7 b' class Post(models.Model, Viewable):' | |||||
230 | return self.threads |
|
230 | return self.threads | |
231 |
|
231 | |||
232 | def get_view(self, moderator=False, need_open_link=False, |
|
232 | def get_view(self, moderator=False, need_open_link=False, | |
233 | truncated=False, *args, **kwargs) -> str: |
|
233 | truncated=False, reply_link=False, *args, **kwargs) -> str: | |
234 | """ |
|
234 | """ | |
235 | Renders post's HTML view. Some of the post params can be passed over |
|
235 | Renders post's HTML view. Some of the post params can be passed over | |
236 | kwargs for the means of caching (if we view the thread, some params |
|
236 | kwargs for the means of caching (if we view the thread, some params | |
@@ -239,22 +239,28 b' class Post(models.Model, Viewable):' | |||||
239 |
|
239 | |||
240 | thread = self.get_thread() |
|
240 | thread = self.get_thread() | |
241 | is_opening = kwargs.get(PARAMETER_IS_OPENING, self.is_opening()) |
|
241 | is_opening = kwargs.get(PARAMETER_IS_OPENING, self.is_opening()) | |
242 | can_bump = kwargs.get(PARAMETER_BUMPABLE, thread.can_bump()) |
|
|||
243 |
|
242 | |||
244 | if is_opening: |
|
243 | if is_opening: | |
245 | opening_post_id = self.id |
|
244 | opening_post_id = self.id | |
246 | else: |
|
245 | else: | |
247 | opening_post_id = thread.get_opening_post_id() |
|
246 | opening_post_id = thread.get_opening_post_id() | |
248 |
|
247 | |||
|
248 | css_class = 'post' | |||
|
249 | if thread.archived: | |||
|
250 | css_class += ' archive_post' | |||
|
251 | elif not thread.can_bump(): | |||
|
252 | css_class += ' dead_post' | |||
|
253 | ||||
249 | return render_to_string('boards/post.html', { |
|
254 | return render_to_string('boards/post.html', { | |
250 | PARAMETER_POST: self, |
|
255 | PARAMETER_POST: self, | |
251 | PARAMETER_MODERATOR: moderator, |
|
256 | PARAMETER_MODERATOR: moderator, | |
252 | PARAMETER_IS_OPENING: is_opening, |
|
257 | PARAMETER_IS_OPENING: is_opening, | |
253 | PARAMETER_THREAD: thread, |
|
258 | PARAMETER_THREAD: thread, | |
254 |
PARAMETER_ |
|
259 | PARAMETER_CSS_CLASS: css_class, | |
255 | PARAMETER_NEED_OPEN_LINK: need_open_link, |
|
260 | PARAMETER_NEED_OPEN_LINK: need_open_link, | |
256 | PARAMETER_TRUNCATED: truncated, |
|
261 | PARAMETER_TRUNCATED: truncated, | |
257 | PARAMETER_OP_ID: opening_post_id, |
|
262 | PARAMETER_OP_ID: opening_post_id, | |
|
263 | PARAMETER_REPLY_LINK: reply_link, | |||
258 | }) |
|
264 | }) | |
259 |
|
265 | |||
260 | def get_search_view(self, *args, **kwargs): |
|
266 | def get_search_view(self, *args, **kwargs): |
@@ -5,16 +5,6 b' from django import template' | |||||
5 |
|
5 | |||
6 | IMG_ACTION_URL = '[<a href="{}">{}</a>]' |
|
6 | IMG_ACTION_URL = '[<a href="{}">{}</a>]' | |
7 |
|
7 | |||
8 | PARAM_POST = 'post' |
|
|||
9 | PARAM_MODERATOR = 'moderator' |
|
|||
10 | PARAM_OP = 'is_opening' |
|
|||
11 | PARAM_THREAD = 'thread' |
|
|||
12 | PARAM_CSS_CLASS = 'css_class' |
|
|||
13 | PARAM_OPEN_LINK = 'need_open_link' |
|
|||
14 | PARAM_TRUNCATED = 'truncated' |
|
|||
15 | PARAM_OP_ID = 'opening_post_id' |
|
|||
16 | PARAM_REPLY_LINK = 'reply_link' |
|
|||
17 |
|
||||
18 |
|
8 | |||
19 | register = template.Library() |
|
9 | register = template.Library() | |
20 |
|
10 | |||
@@ -49,36 +39,7 b' def image_actions(*args, **kwargs):' | |||||
49 | action['link'] % image_link, action['name'])for action in actions]) |
|
39 | action['link'] % image_link, action['name'])for action in actions]) | |
50 |
|
40 | |||
51 |
|
41 | |||
52 |
@register. |
|
42 | @register.simple_tag(name='post_view') | |
53 | def post_view(post, moderator=False, need_open_link=False, truncated=False, |
|
43 | def post_view(post, *args, **kwargs): | |
54 | reply_link=False, **kwargs): |
|
44 | return post.get_view(*args, **kwargs) | |
55 | """ |
|
|||
56 | Get post |
|
|||
57 | """ |
|
|||
58 |
|
||||
59 | thread = post.get_thread() |
|
|||
60 | is_opening = post.is_opening() |
|
|||
61 |
|
||||
62 | if is_opening: |
|
|||
63 | opening_post_id = post.id |
|
|||
64 | else: |
|
|||
65 | opening_post_id = thread.get_opening_post_id() |
|
|||
66 |
|
45 | |||
67 | css_class = 'post' |
|
|||
68 | if thread.archived: |
|
|||
69 | css_class += ' archive_post' |
|
|||
70 | elif not thread.can_bump(): |
|
|||
71 | css_class += ' dead_post' |
|
|||
72 |
|
||||
73 | return { |
|
|||
74 | PARAM_POST: post, |
|
|||
75 | PARAM_MODERATOR: moderator, |
|
|||
76 | PARAM_OP: is_opening, |
|
|||
77 | PARAM_THREAD: thread, |
|
|||
78 | PARAM_CSS_CLASS: css_class, |
|
|||
79 | PARAM_OPEN_LINK: need_open_link, |
|
|||
80 | PARAM_TRUNCATED: truncated, |
|
|||
81 | PARAM_OP_ID: opening_post_id, |
|
|||
82 | PARAM_REPLY_LINK: reply_link, |
|
|||
83 | } |
|
|||
84 |
|
General Comments 0
You need to be logged in to leave comments.
Login now