Fix linking to comments.
authorElrond <elrond+mediagoblin.org@samba-tng.org>
Thu, 17 Jan 2013 22:50:51 +0000 (23:50 +0100)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Thu, 17 Jan 2013 22:57:40 +0000 (23:57 +0100)
when linking to a comment in a MediaEntry, the page did not
contain a <a name="comment"> because, well:

We fetched a string comment-id from the routing. And the
pagination code tried to compare that to the int id on the
comment.

Fix is to let routing fetch an int from the url. Easy.

Relatedly remove duplicated comment_id fetching from the
URL in the view.

mediagoblin/user_pages/routing.py
mediagoblin/user_pages/views.py

index a94314058e72f57d6e684ce8e5bd00fa64905d67..2b2283557ed60ece3606a3e5fb1688f61b87fa07 100644 (file)
@@ -37,7 +37,7 @@ add_route('mediagoblin.user_pages.user_gallery',
           'mediagoblin.user_pages.views:user_gallery')
 
 add_route('mediagoblin.user_pages.media_home.view_comment',
-          '/u/<string:user>/m/<string:media>/c/<string:comment>/',
+          '/u/<string:user>/m/<string:media>/c/<int:comment>/',
           'mediagoblin.user_pages.views:media_home')
 
 add_route('mediagoblin.user_pages.atom_feed',
index d1ec23dc41d670d027711952fd579c3015a56a0f..dea47fbf4bf64bf38ff8e7536114d2bd7f84fae2 100644 (file)
@@ -110,12 +110,13 @@ def media_home(request, media, page, **kwargs):
     """
     'Homepage' of a MediaEntry()
     """
-    if request.matchdict.get('comment', None):
+    comment_id = request.matchdict.get('comment', None)
+    if comment_id:
         pagination = Pagination(
             page, media.get_comments(
                 mg_globals.app_config['comments_ascending']),
             MEDIA_COMMENTS_PER_PAGE,
-            request.matchdict.get('comment'))
+            comment_id)
     else:
         pagination = Pagination(
             page, media.get_comments(