##// END OF EJS Templates
Some more speedups to the post view
neko259 -
r625:2acaa774 default
parent child Browse files
Show More
@@ -298,7 +298,7 b' class Post(models.Model):'
298 298 thread.last_edit_time = edit_time
299 299 thread.save()
300 300
301 def get_url(self):
301 def get_url(self, thread=None):
302 302 """
303 303 Gets full url to the post.
304 304 """
@@ -307,7 +307,10 b' class Post(models.Model):'
307 307 link = cache.get(cache_key)
308 308
309 309 if not link:
310 opening_id = self.get_thread().get_opening_post_id()
310 if not thread:
311 thread = self.get_thread()
312
313 opening_id = thread.get_opening_post_id()
311 314
312 315 if self.id != opening_id:
313 316 link = reverse('thread', kwargs={
@@ -31,7 +31,7 b''
31 31 <div class="message">
32 32 <div class="post-info">
33 33 <span class="title">{{ post.title }}</span>
34 <a class="post_id" href="{% post_object_url post %}">
34 <a class="post_id" href="{% post_object_url post thread=thread %}">
35 35 ({{ post.id }}) </a>
36 36 [<span class="pub_time">{{ post.pub_time }}</span>]
37 37 {% if thread.archived %}
@@ -73,8 +73,7 b''
73 73 <div class="refmap">
74 74 {% trans "Replies" %}:
75 75 {% for ref_post in refposts %}
76 <a href="{% post_object_url ref_post %}">&gt;&gt;{{ ref_post.id }}</a
77 >{% if not forloop.last %},{% endif %}
76 <a href="{% post_object_url ref_post thread=thread %}">&gt;&gt;{{ ref_post.id }}</a>{% if not forloop.last %},{% endif %}
78 77 {% endfor %}
79 78 </div>
80 79 {% endif %}
@@ -33,16 +33,14 b''
33 33
34 34 <div class="thread">
35 35 {% with can_bump=thread.can_bump %}
36 {% with opening_post_id=thread.get_opening_post.id %}
37 36 {% for post in thread.get_replies %}
38 37 {% if forloop.first %}
39 {% post_view post moderator=moderator is_opening=True thread=thread can_bump=can_bump opening_post_id=opening_post_id %}
38 {% post_view post moderator=moderator is_opening=True thread=thread can_bump=can_bump opening_post_id=opening_post.id %}
40 39 {% else %}
41 {% post_view post moderator=moderator is_opening=False thread=thread can_bump=can_bump opening_post_id=opening_post_id %}
40 {% post_view post moderator=moderator is_opening=False thread=thread can_bump=can_bump opening_post_id=opening_post.id %}
42 41 {% endif %}
43 42 {% endfor %}
44 43 {% endwith %}
45 {% endwith %}
46 44 </div>
47 45
48 46 {% if not thread.archived %}
@@ -30,7 +30,12 b' def post_url(*args, **kwargs):'
30 30 def post_object_url(*args, **kwargs):
31 31 post = args[0]
32 32
33 return post.get_url()
33 if 'thread' in kwargs:
34 post_thread = kwargs['thread']
35 else:
36 post_thread = None
37
38 return post.get_url(thread=post_thread)
34 39
35 40
36 41 @register.simple_tag(name='image_actions')
@@ -45,7 +45,7 b' class ThreadView(BaseBoardView, PostMixi'
45 45 float(context['posts_left']) /
46 46 neboard.settings.MAX_POSTS_PER_THREAD * 100)
47 47
48 context['opening_post'] = thread_to_show.get_opening_post()
48 context['opening_post'] = opening_post
49 49
50 50 document = 'boards/thread.html'
51 51 elif MODE_GALLERY == mode:
General Comments 0
You need to be logged in to leave comments. Login now