Show More
@@ -100,7 +100,7 b' class PostManager(models.Manager):' | |||||
100 | if page != ALL_PAGES: |
|
100 | if page != ALL_PAGES: | |
101 | thread_count = threads.count() |
|
101 | thread_count = threads.count() | |
102 |
|
102 | |||
103 |
if page < self.get |
|
103 | if page < self._get_page_count(thread_count): | |
104 | start_thread = page * settings.THREADS_PER_PAGE |
|
104 | start_thread = page * settings.THREADS_PER_PAGE | |
105 | end_thread = min(start_thread + settings.THREADS_PER_PAGE, |
|
105 | end_thread = min(start_thread + settings.THREADS_PER_PAGE, | |
106 | thread_count) |
|
106 | thread_count) | |
@@ -131,8 +131,7 b' class PostManager(models.Manager):' | |||||
131 | else: |
|
131 | else: | |
132 | threads = self.filter(thread=None) |
|
132 | threads = self.filter(thread=None) | |
133 |
|
133 | |||
134 |
return |
|
134 | return self._get_page_count(threads.count()) | |
135 | settings.THREADS_PER_PAGE))) |
|
|||
136 |
|
135 | |||
137 | def _delete_old_threads(self): |
|
136 | def _delete_old_threads(self): | |
138 | """ |
|
137 | """ | |
@@ -162,6 +161,9 b' class PostManager(models.Manager):' | |||||
162 |
|
|
161 | if ref_post.count() > 0: | |
163 |
|
|
162 | ref_post[0].referenced_posts.add(post) | |
164 |
|
163 | |||
|
164 | def _get_page_count(self, thread_count): | |||
|
165 | return int(math.ceil(thread_count / float(settings.THREADS_PER_PAGE))) | |||
|
166 | ||||
165 |
|
167 | |||
166 | class TagManager(models.Manager): |
|
168 | class TagManager(models.Manager): | |
167 |
|
169 |
@@ -14,6 +14,8 b'' | |||||
14 |
|
14 | |||
15 | {% block content %} |
|
15 | {% block content %} | |
16 |
|
16 | |||
|
17 | {% get_current_language as LANGUAGE_CODE %} | |||
|
18 | ||||
17 | {% if tag %} |
|
19 | {% if tag %} | |
18 | <div class="tag_info"> |
|
20 | <div class="tag_info"> | |
19 | <h2> |
|
21 | <h2> | |
@@ -31,6 +33,7 b'' | |||||
31 |
|
33 | |||
32 | {% if threads %} |
|
34 | {% if threads %} | |
33 | {% for thread in threads %} |
|
35 | {% for thread in threads %} | |
|
36 | {% cache 600 thread_short thread.thread.last_edit_time moderator LANGUAGE_CODE %} | |||
34 | <div class="thread"> |
|
37 | <div class="thread"> | |
35 | {% if thread.bumpable %} |
|
38 | {% if thread.bumpable %} | |
36 | <div class="post" id="{{ thread.thread.id }}"> |
|
39 | <div class="post" id="{{ thread.thread.id }}"> | |
@@ -93,9 +96,9 b'' | |||||
93 | {% endif %} |
|
96 | {% endif %} | |
94 | </div> |
|
97 | </div> | |
95 | </div> |
|
98 | </div> | |
96 |
{% if thread. |
|
99 | {% if thread.last_replies.exists %} | |
97 | <div class="last-replies"> |
|
100 | <div class="last-replies"> | |
98 |
{% for post in thread. |
|
101 | {% for post in thread.last_replies %} | |
99 | {% if thread.bumpable %} |
|
102 | {% if thread.bumpable %} | |
100 | <div class="post" id="{{ post.id }}"> |
|
103 | <div class="post" id="{{ post.id }}"> | |
101 | {% else %} |
|
104 | {% else %} | |
@@ -137,6 +140,7 b'' | |||||
137 | </div> |
|
140 | </div> | |
138 | {% endif %} |
|
141 | {% endif %} | |
139 | </div> |
|
142 | </div> | |
|
143 | {% endcache %} | |||
140 | {% endfor %} |
|
144 | {% endfor %} | |
141 | {% else %} |
|
145 | {% else %} | |
142 | <div class="post"> |
|
146 | <div class="post"> |
@@ -47,8 +47,11 b' def index(request, page=0):' | |||||
47 |
|
47 | |||
48 | threads = [] |
|
48 | threads = [] | |
49 | for thread in Post.objects.get_threads(page=int(page)): |
|
49 | for thread in Post.objects.get_threads(page=int(page)): | |
50 |
threads.append({ |
|
50 | threads.append({ | |
51 | 'bumpable': thread.can_bump()}) |
|
51 | 'thread': thread, | |
|
52 | 'bumpable': thread.can_bump(), | |||
|
53 | 'last_replies': thread.get_last_replies(), | |||
|
54 | }) | |||
52 |
|
55 | |||
53 | context['threads'] = None if len(threads) == 0 else threads |
|
56 | context['threads'] = None if len(threads) == 0 else threads | |
54 | context['form'] = form |
|
57 | context['form'] = form | |
@@ -121,8 +124,11 b' def tag(request, tag_name, page=0):' | |||||
121 | tag = get_object_or_404(Tag, name=tag_name) |
|
124 | tag = get_object_or_404(Tag, name=tag_name) | |
122 | threads = [] |
|
125 | threads = [] | |
123 | for thread in Post.objects.get_threads(tag=tag, page=int(page)): |
|
126 | for thread in Post.objects.get_threads(tag=tag, page=int(page)): | |
124 |
threads.append({ |
|
127 | threads.append({ | |
125 | 'bumpable': thread.can_bump()}) |
|
128 | 'thread': thread, | |
|
129 | 'bumpable': thread.can_bump(), | |||
|
130 | 'last_replies': thread.get_last_replies(), | |||
|
131 | }) | |||
126 |
|
132 | |||
127 | if request.method == 'POST': |
|
133 | if request.method == 'POST': | |
128 | form = ThreadForm(request.POST, request.FILES, |
|
134 | form = ThreadForm(request.POST, request.FILES, |
General Comments 0
You need to be logged in to leave comments.
Login now