# HG changeset patch # User neko259 # Date 2015-05-09 11:42:52 # Node ID e92b66f880c11aea22abe826b78b6adc9fb645b9 # Parent 1c4910b708b2893e29f33761642e81005f5341b2 Use get_absolute_url instead of get_url for post, tag and thread diff --git a/boards/mdx_neboard.py b/boards/mdx_neboard.py --- a/boards/mdx_neboard.py +++ b/boards/mdx_neboard.py @@ -130,7 +130,7 @@ def render_reflink(tag_name, value, opti try: post = boards.models.Post.objects.get(id=post_id) - result = '>>%s' % (post.get_url(), post_id) + result = '>>%s' % (post.get_absolute_url(), post_id) except ObjectDoesNotExist: pass diff --git a/boards/models/post/__init__.py b/boards/models/post/__init__.py --- a/boards/models/post/__init__.py +++ b/boards/models/post/__init__.py @@ -199,7 +199,7 @@ class Post(models.Model, Viewable): the server from recalculating the map on every post show. """ - post_urls = [REFMAP_STR.format(refpost.get_url(), refpost.id) + post_urls = [REFMAP_STR.format(refpost.get_absolute_url(), refpost.id) for refpost in self.referenced_posts.all()] self.refmap = ', '.join(post_urls) @@ -214,10 +214,6 @@ class Post(models.Model, Viewable): return self.get_thread().get_opening_post_id() == self.id - # TODO Remove this and use get_absolute_url method - def get_url(self): - return self.url - def get_absolute_url(self): return self.url diff --git a/boards/models/tag.py b/boards/models/tag.py --- a/boards/models/tag.py +++ b/boards/models/tag.py @@ -56,13 +56,9 @@ class Tag(models.Model, Viewable): def get_thread_count(self) -> int: return self.get_threads().count() - # TODO Remove this and use get_absolute_url - def get_url(self): + def get_absolute_url(self): return reverse('tag', kwargs={'tag_name': self.name}) - def get_absolute_url(self): - return self.get_url() - def get_threads(self): return self.thread_set.order_by('-bump_time') diff --git a/boards/templates/boards/post.html b/boards/templates/boards/post.html --- a/boards/templates/boards/post.html +++ b/boards/templates/boards/post.html @@ -5,7 +5,7 @@
{% endwith %}
diff --git a/boards/templatetags/board.py b/boards/templatetags/board.py --- a/boards/templatetags/board.py +++ b/boards/templatetags/board.py @@ -26,7 +26,7 @@ def post_url(*args, **kwargs): post = get_object_or_404('Post', id=post_id) - return post.get_url() + return post.get_absolute_url() @register.simple_tag(name='image_actions') diff --git a/boards/views/all_threads.py b/boards/views/all_threads.py --- a/boards/views/all_threads.py +++ b/boards/views/all_threads.py @@ -158,7 +158,7 @@ class AllThreadsView(PostMixin, BaseBoar post.notify_clients() if html_response: - return redirect(post.get_url()) + return redirect(post.get_absolute_url()) def get_threads(self): """ diff --git a/boards/views/thread/thread.py b/boards/views/thread/thread.py --- a/boards/views/thread/thread.py +++ b/boards/views/thread/thread.py @@ -38,7 +38,8 @@ class ThreadView(BaseBoardView, PostMixi # If this is not OP, don't show it as it is if not opening_post.is_opening(): - return redirect(opening_post.get_thread().get_opening_post().get_url()) + return redirect(opening_post.get_thread().get_opening_post() + .get_absolute_url()) if not form: form = PostForm(error_class=PlainErrorList) @@ -111,7 +112,7 @@ class ThreadView(BaseBoardView, PostMixi if html_response: if opening_post: - return redirect(post.get_url()) + return redirect(post.get_absolute_url()) else: return post