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