Show More
@@ -4,11 +4,8 b'' | |||
|
4 | 4 | |
|
5 | 5 | {% get_current_language as LANGUAGE_CODE %} |
|
6 | 6 | |
|
7 | {% with thread=post.thread_new %} | |
|
8 | {% with bumpable=thread.can_bump %} | |
|
9 | 7 | {% cache 600 post post.id post.last_edit_time thread.archived bumpable truncated moderator LANGUAGE_CODE need_open_link %} |
|
10 | 8 | |
|
11 | {% with is_opening=post.is_opening %} | |
|
12 | 9 | {% spaceless %} |
|
13 | 10 | {% if thread.archived %} |
|
14 | 11 | <div class="post archive_post" id="{{ post.id }}"> |
@@ -97,7 +94,4 b'' | |||
|
97 | 94 | {% endif %} |
|
98 | 95 | </div> |
|
99 | 96 | {% endspaceless %} |
|
100 | {% endwith %} | |
|
101 | 97 | {% endcache %} |
|
102 | {% endwith %} | |
|
103 | {% endwith %} |
@@ -74,7 +74,8 b'' | |||
|
74 | 74 | {% for thread in threads %} |
|
75 | 75 | {% cache 600 thread_short thread.id thread.last_edit_time moderator LANGUAGE_CODE %} |
|
76 | 76 | <div class="thread"> |
|
77 | {% post_view_truncated thread.get_opening_post True moderator %} | |
|
77 | {% with can_bump=thread.can_bump %} | |
|
78 | {% post_view_truncated thread.get_opening_post True moderator is_opening=True thread=thread can_bump=can_bump %} | |
|
78 | 79 | {% if not thread.archived %} |
|
79 | 80 | {% if thread.get_last_replies.exists %} |
|
80 | 81 | {% if thread.get_skipped_replies_count %} |
@@ -86,11 +87,12 b'' | |||
|
86 | 87 | {% endif %} |
|
87 | 88 | <div class="last-replies"> |
|
88 | 89 | {% for post in thread.get_last_replies %} |
|
89 | {% post_view_truncated post moderator=moderator%} | |
|
90 | {% post_view_truncated post moderator=moderator is_opening=False thread=thread can_bump=can_bump %} | |
|
90 | 91 | {% endfor %} |
|
91 | 92 | </div> |
|
92 | 93 | {% endif %} |
|
93 | 94 | {% endif %} |
|
95 | {% endwith %} | |
|
94 | 96 | </div> |
|
95 | 97 | {% endcache %} |
|
96 | 98 | {% endfor %} |
@@ -32,9 +32,15 b'' | |||
|
32 | 32 | {% endif %} |
|
33 | 33 | |
|
34 | 34 | <div class="thread"> |
|
35 | {% with can_bump=thread.can_bump %} | |
|
35 | 36 | {% for post in thread.get_replies %} |
|
36 | {% post_view post moderator=moderator %} | |
|
37 | {% if forloop.first %} | |
|
38 | {% post_view post moderator=moderator is_opening=True thread=thread can_bump=can_bump %} | |
|
39 | {% else %} | |
|
40 | {% post_view post moderator=moderator is_opening=False thread=thread can_bump=can_bump %} | |
|
41 | {% endif %} | |
|
37 | 42 | {% endfor %} |
|
43 | {% endwith %} | |
|
38 | 44 | </div> |
|
39 | 45 | |
|
40 | 46 | {% if not thread.archived %} |
@@ -50,27 +50,63 b' def image_actions(*args, **kwargs):' | |||
|
50 | 50 | |
|
51 | 51 | |
|
52 | 52 | @register.inclusion_tag('boards/post.html', name='post_view') |
|
53 | def post_view(post, moderator=False): | |
|
53 | def post_view(post, moderator=False, **kwargs): | |
|
54 | 54 | """ |
|
55 | 55 | Get post |
|
56 | 56 | """ |
|
57 | 57 | |
|
58 | if 'is_opening' in kwargs: | |
|
59 | is_opening = kwargs['is_opening'] | |
|
60 | else: | |
|
61 | is_opening = post.is_opening() | |
|
62 | ||
|
63 | if 'thread' in kwargs: | |
|
64 | thread = kwargs['thread'] | |
|
65 | else: | |
|
66 | thread = post.thread_new | |
|
67 | ||
|
68 | if 'can_bump' in kwargs: | |
|
69 | can_bump = kwargs['can_bump'] | |
|
70 | else: | |
|
71 | can_bump = thread.can_bump() | |
|
72 | ||
|
58 | 73 | return { |
|
59 | 74 | 'post': post, |
|
60 | 75 | 'moderator': moderator, |
|
76 | 'is_opening': is_opening, | |
|
77 | 'thread': thread, | |
|
78 | 'bumpable': can_bump, | |
|
61 | 79 | } |
|
62 | 80 | |
|
63 | 81 | |
|
64 | 82 | @register.inclusion_tag('boards/post.html', name='post_view_truncated') |
|
65 | def post_view_truncated(post, need_open_link=False, moderator=False): | |
|
83 | def post_view_truncated(post, need_open_link=False, moderator=False, **kwargs): | |
|
66 | 84 | """ |
|
67 | 85 | Get post with truncated text. If the 'open' or 'reply' link is needed, pass |
|
68 | 86 | the second parameter as True. |
|
69 | 87 | """ |
|
70 | 88 | |
|
89 | if 'is_opening' in kwargs: | |
|
90 | is_opening = kwargs['is_opening'] | |
|
91 | else: | |
|
92 | is_opening = post.is_opening() | |
|
93 | ||
|
94 | if 'thread' in kwargs: | |
|
95 | thread = kwargs['thread'] | |
|
96 | else: | |
|
97 | thread = post.thread_new | |
|
98 | ||
|
99 | if 'can_bump' in kwargs: | |
|
100 | can_bump = kwargs['can_bump'] | |
|
101 | else: | |
|
102 | can_bump = thread.can_bump() | |
|
103 | ||
|
71 | 104 | return { |
|
72 | 105 | 'post': post, |
|
73 | 106 | 'truncated': True, |
|
74 | 107 | 'need_open_link': need_open_link, |
|
75 | 108 | 'moderator': moderator, |
|
109 | 'is_opening': is_opening, | |
|
110 | 'thread': thread, | |
|
111 | 'bumpable': can_bump, | |
|
76 | 112 | } |
General Comments 0
You need to be logged in to leave comments.
Login now