##// END OF EJS Templates
Using opening post ID from cache, not passing it to the post view
neko259 -
r621:59a1deab default
parent child Browse files
Show More
@@ -291,7 +291,7 b' class Post(models.Model):'
291 thread.last_edit_time = edit_time
291 thread.last_edit_time = edit_time
292 thread.save()
292 thread.save()
293
293
294 def get_url(self, opening_id=None):
294 def get_url(self):
295 """
295 """
296 Get full url to this post
296 Get full url to this post
297 """
297 """
@@ -300,9 +300,7 b' class Post(models.Model):'
300 link = cache.get(cache_key)
300 link = cache.get(cache_key)
301
301
302 if not link:
302 if not link:
303 if not opening_id:
303 opening_id = self.get_thread().get_opening_post_id()
304 opening_post = self.get_thread().get_opening_post()
305 opening_id = opening_post.id
306
304
307 if self.id != opening_id:
305 if self.id != opening_id:
308 link = reverse('thread', kwargs={
306 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 opening_post_id %}">
34 <a class="post_id" href="{% post_object_url post %}">
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,7 +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 opening_post_id %}">&gt;&gt;{{ ref_post.id }}</a
76 <a href="{% post_object_url ref_post %}">&gt;&gt;{{ ref_post.id }}</a
77 >{% if not forloop.last %},{% endif %}
77 >{% if not forloop.last %},{% endif %}
78 {% endfor %}
78 {% endfor %}
79 </div>
79 </div>
@@ -20,25 +20,17 b' actions = ['
20 @register.simple_tag(name='post_url')
20 @register.simple_tag(name='post_url')
21 def post_url(*args, **kwargs):
21 def post_url(*args, **kwargs):
22 post_id = args[0]
22 post_id = args[0]
23 if len(args) > 1:
24 opening_post_id = args[1]
25 else:
26 opening_post_id = None
27
23
28 post = get_object_or_404(Post, id=post_id)
24 post = get_object_or_404(Post, id=post_id)
29
25
30 return post.get_url(opening_post_id)
26 return post.get_url()
31
27
32
28
33 @register.simple_tag(name='post_object_url')
29 @register.simple_tag(name='post_object_url')
34 def post_object_url(*args, **kwargs):
30 def post_object_url(*args, **kwargs):
35 post = args[0]
31 post = args[0]
36 if len(args) > 1:
37 opening_post_id = args[1]
38 else:
39 opening_post_id = None
40
32
41 return post.get_url(opening_post_id)
33 return post.get_url()
42
34
43
35
44 @register.simple_tag(name='image_actions')
36 @register.simple_tag(name='image_actions')
@@ -78,10 +70,7 b' def post_view(post, moderator=False, nee'
78 else:
70 else:
79 can_bump = thread.can_bump()
71 can_bump = thread.can_bump()
80
72
81 if 'opening_post_id' in kwargs:
73 opening_post_id = thread.get_opening_post_id()
82 opening_post_id = kwargs['opening_post_id']
83 else:
84 opening_post_id = thread.get_opening_post().id
85
74
86 return {
75 return {
87 'post': post,
76 'post': post,
General Comments 0
You need to be logged in to leave comments. Login now