Fix linking to comments.

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.
This commit is contained in:
Elrond 2013-01-17 23:50:51 +01:00
parent 00cf28da21
commit 7d16a01bae
2 changed files with 4 additions and 3 deletions

View 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',

View 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(