##// 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 thread.last_edit_time = edit_time
298 thread.last_edit_time = edit_time
299 thread.save()
299 thread.save()
300
300
301 def get_url(self):
301 def get_url(self, thread=None):
302 """
302 """
303 Gets full url to the post.
303 Gets full url to the post.
304 """
304 """
@@ -307,7 +307,10 b' class Post(models.Model):'
307 link = cache.get(cache_key)
307 link = cache.get(cache_key)
308
308
309 if not link:
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 if self.id != opening_id:
315 if self.id != opening_id:
313 link = reverse('thread', kwargs={
316 link = reverse('thread', kwargs={
@@ -31,7 +31,7 b''
31 <div class="message">
31 <div class="message">
32 <div class="post-info">
32 <div class="post-info">
33 <span class="title">{{ post.title }}</span>
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 ({{ post.id }}) </a>
35 ({{ post.id }}) </a>
36 [<span class="pub_time">{{ post.pub_time }}</span>]
36 [<span class="pub_time">{{ post.pub_time }}</span>]
37 {% if thread.archived %}
37 {% if thread.archived %}
@@ -73,8 +73,7 b''
73 <div class="refmap">
73 <div class="refmap">
74 {% trans "Replies" %}:
74 {% trans "Replies" %}:
75 {% for ref_post in refposts %}
75 {% for ref_post in refposts %}
76 <a href="{% post_object_url ref_post %}">&gt;&gt;{{ ref_post.id }}</a
76 <a href="{% post_object_url ref_post thread=thread %}">&gt;&gt;{{ ref_post.id }}</a>{% if not forloop.last %},{% endif %}
77 >{% if not forloop.last %},{% endif %}
78 {% endfor %}
77 {% endfor %}
79 </div>
78 </div>
80 {% endif %}
79 {% endif %}
@@ -33,16 +33,14 b''
33
33
34 <div class="thread">
34 <div class="thread">
35 {% with can_bump=thread.can_bump %}
35 {% with can_bump=thread.can_bump %}
36 {% with opening_post_id=thread.get_opening_post.id %}
37 {% for post in thread.get_replies %}
36 {% for post in thread.get_replies %}
38 {% if forloop.first %}
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 {% else %}
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 {% endif %}
41 {% endif %}
43 {% endfor %}
42 {% endfor %}
44 {% endwith %}
43 {% endwith %}
45 {% endwith %}
46 </div>
44 </div>
47
45
48 {% if not thread.archived %}
46 {% if not thread.archived %}
@@ -30,7 +30,12 b' def post_url(*args, **kwargs):'
30 def post_object_url(*args, **kwargs):
30 def post_object_url(*args, **kwargs):
31 post = args[0]
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 @register.simple_tag(name='image_actions')
41 @register.simple_tag(name='image_actions')
@@ -45,7 +45,7 b' class ThreadView(BaseBoardView, PostMixi'
45 float(context['posts_left']) /
45 float(context['posts_left']) /
46 neboard.settings.MAX_POSTS_PER_THREAD * 100)
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 document = 'boards/thread.html'
50 document = 'boards/thread.html'
51 elif MODE_GALLERY == mode:
51 elif MODE_GALLERY == mode:
General Comments 0
You need to be logged in to leave comments. Login now