diff gpp/forums/views/main.py @ 529:7388cdf61b25

For #241, add a URL to view the last post in a forum topic.
author Brian Neal <bgneal@gmail.com>
date Thu, 22 Dec 2011 02:10:27 +0000
parents 82b97697312e
children 98b373ca09f3
line wrap: on
line diff
--- a/gpp/forums/views/main.py	Wed Dec 21 01:25:10 2011 +0000
+++ b/gpp/forums/views/main.py	Thu Dec 22 02:10:27 2011 +0000
@@ -287,6 +287,19 @@
     return HttpResponseRedirect(topic_url)
 
 
+def topic_latest(request, id):
+    """
+    This view shows the latest (last) post in a given topic.
+
+    """
+    topic = get_object_or_404(Topic.objects.select_related(depth=1), pk=id)
+
+    if topic.last_post:
+        return _goto_post(topic.last_post)
+
+    raise Http404
+
+
 @login_required
 def new_topic(request, slug):
     """