##// END OF EJS Templates
Use get_absolute_url instead of get_url for post, tag and thread
neko259 -
r1160:e92b66f8 default
parent child Browse files
Show More
@@ -130,7 +130,7 b' def render_reflink(tag_name, value, opti'
130 try:
130 try:
131 post = boards.models.Post.objects.get(id=post_id)
131 post = boards.models.Post.objects.get(id=post_id)
132
132
133 result = '<a href="%s">&gt;&gt;%s</a>' % (post.get_url(), post_id)
133 result = '<a href="%s">&gt;&gt;%s</a>' % (post.get_absolute_url(), post_id)
134 except ObjectDoesNotExist:
134 except ObjectDoesNotExist:
135 pass
135 pass
136
136
@@ -199,7 +199,7 b' class Post(models.Model, Viewable):'
199 the server from recalculating the map on every post show.
199 the server from recalculating the map on every post show.
200 """
200 """
201
201
202 post_urls = [REFMAP_STR.format(refpost.get_url(), refpost.id)
202 post_urls = [REFMAP_STR.format(refpost.get_absolute_url(), refpost.id)
203 for refpost in self.referenced_posts.all()]
203 for refpost in self.referenced_posts.all()]
204
204
205 self.refmap = ', '.join(post_urls)
205 self.refmap = ', '.join(post_urls)
@@ -214,10 +214,6 b' class Post(models.Model, Viewable):'
214
214
215 return self.get_thread().get_opening_post_id() == self.id
215 return self.get_thread().get_opening_post_id() == self.id
216
216
217 # TODO Remove this and use get_absolute_url method
218 def get_url(self):
219 return self.url
220
221 def get_absolute_url(self):
217 def get_absolute_url(self):
222 return self.url
218 return self.url
223
219
@@ -56,13 +56,9 b' class Tag(models.Model, Viewable):'
56 def get_thread_count(self) -> int:
56 def get_thread_count(self) -> int:
57 return self.get_threads().count()
57 return self.get_threads().count()
58
58
59 # TODO Remove this and use get_absolute_url
59 def get_absolute_url(self):
60 def get_url(self):
61 return reverse('tag', kwargs={'tag_name': self.name})
60 return reverse('tag', kwargs={'tag_name': self.name})
62
61
63 def get_absolute_url(self):
64 return self.get_url()
65
66 def get_threads(self):
62 def get_threads(self):
67 return self.thread_set.order_by('-bump_time')
63 return self.thread_set.order_by('-bump_time')
68
64
@@ -5,7 +5,7 b''
5
5
6 <div class="{{ css_class }}" id="{{ post.id }}" data-uid="{{ post.uid }}">
6 <div class="{{ css_class }}" id="{{ post.id }}" data-uid="{{ post.uid }}">
7 <div class="post-info">
7 <div class="post-info">
8 <a class="post_id" href="{{ post.get_url }}">({{ post.get_absolute_id }})</a>
8 <a class="post_id" href="{{ post.get_absolute_url }}">({{ post.get_absolute_id }})</a>
9 <span class="title">{{ post.title }}</span>
9 <span class="title">{{ post.title }}</span>
10 <span class="pub_time"><time datetime="{{ post.pub_time|date:'c' }}">{{ post.pub_time }}</time></span>
10 <span class="pub_time"><time datetime="{{ post.pub_time|date:'c' }}">{{ post.pub_time }}</time></span>
11 {% comment %}
11 {% comment %}
@@ -32,7 +32,7 b''
32 <div class="post">
32 <div class="post">
33 <div class="title">{{ banner.title }}</div>
33 <div class="title">{{ banner.title }}</div>
34 <div>{{ banner.text }}</div>
34 <div>{{ banner.text }}</div>
35 <div>{% trans 'Related message' %}: <a href="{{ banner.post.get_url }}">>>{{ banner.post.id }}</a></div>
35 <div>{% trans 'Related message' %}: <a href="{{ banner.post.get_absolute_url }}">>>{{ banner.post.id }}</a></div>
36 </div>
36 </div>
37 {% endfor %}
37 {% endfor %}
38
38
@@ -32,7 +32,7 b''
32 {{ image.width }}x{{ image.height }}
32 {{ image.width }}x{{ image.height }}
33 {% image_actions image.image.url request.get_host %}
33 {% image_actions image.image.url request.get_host %}
34 <br />
34 <br />
35 <a href="{{ post.get_url }}">>>{{ post.id }}</a>
35 <a href="{{ post.get_absolute_url }}">>>{{ post.id }}</a>
36 </div>
36 </div>
37 {% endwith %}
37 {% endwith %}
38 </div>
38 </div>
@@ -26,7 +26,7 b' def post_url(*args, **kwargs):'
26
26
27 post = get_object_or_404('Post', id=post_id)
27 post = get_object_or_404('Post', id=post_id)
28
28
29 return post.get_url()
29 return post.get_absolute_url()
30
30
31
31
32 @register.simple_tag(name='image_actions')
32 @register.simple_tag(name='image_actions')
@@ -158,7 +158,7 b' class AllThreadsView(PostMixin, BaseBoar'
158 post.notify_clients()
158 post.notify_clients()
159
159
160 if html_response:
160 if html_response:
161 return redirect(post.get_url())
161 return redirect(post.get_absolute_url())
162
162
163 def get_threads(self):
163 def get_threads(self):
164 """
164 """
@@ -38,7 +38,8 b' class ThreadView(BaseBoardView, PostMixi'
38
38
39 # If this is not OP, don't show it as it is
39 # If this is not OP, don't show it as it is
40 if not opening_post.is_opening():
40 if not opening_post.is_opening():
41 return redirect(opening_post.get_thread().get_opening_post().get_url())
41 return redirect(opening_post.get_thread().get_opening_post()
42 .get_absolute_url())
42
43
43 if not form:
44 if not form:
44 form = PostForm(error_class=PlainErrorList)
45 form = PostForm(error_class=PlainErrorList)
@@ -111,7 +112,7 b' class ThreadView(BaseBoardView, PostMixi'
111
112
112 if html_response:
113 if html_response:
113 if opening_post:
114 if opening_post:
114 return redirect(post.get_url())
115 return redirect(post.get_absolute_url())
115 else:
116 else:
116 return post
117 return post
117
118
General Comments 0
You need to be logged in to leave comments. Login now