Pilsburgh / django-forum

Automatically exported from code.google.com/p/django-forum
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Post absolute URL fails in pagination #56

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
You can not directly access a post by the get_absolute_url method if the
thread view is paginated. As a result the 'view last post' links do not
work in the forum and thread list views.

Initially I tried adding ?page=last to the end of the links, but the post
id anchor breaks this.

/#1234?page=last does not work.
/?page=last#1234 does work.

Original issue reported on code.google.com by lu...@die.net.au on 24 Mar 2009 at 8:48

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
This will at least make 'view last post' work

diff --git a/models.py b/models.py
index 37d6e62..03cdda9 100644
--- a/models.py
+++ b/models.py
@@ -244,7 +244,7 @@ class Post(models.Model):
         ordering = ('-time',)

     def get_absolute_url(self):
-        return '%s#post%s' % (self.thread.get_absolute_url(), self.id)
+        return '%s?page=last#post%s' % (self.thread.get_absolute_url(), 
self.id)

     def __unicode__(self):
         return u"%s" % self.id

Original comment by lu...@die.net.au on 13 Apr 2009 at 5:49

GoogleCodeExporter commented 9 years ago
Thanks for the patch. i've checked it in, and will work on a better patch 
sometime
soon to handle cases like having a permalink to a post, links in e-mails, etc.

Patch added in SVN r44.

Original comment by rwpoul...@gmail.com on 3 May 2009 at 12:23