From: Elrond Date: Tue, 20 Dec 2011 17:47:33 +0000 (+0100) Subject: Use media.url_for_self instead of calling urlgen directly X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=0eb649ff7ac3f1eb71eb1d2cb66019a860b2c5c7;p=mediagoblin.git Use media.url_for_self instead of calling urlgen directly Replace urlgen('ID', user=media.get_uploader().username, media=media.*) by media.url_for_self(urlgen) in a few places. It's just a lot nicer! --- diff --git a/mediagoblin/db/mongo/models.py b/mediagoblin/db/mongo/models.py index b068fb06..8cd0da1b 100644 --- a/mediagoblin/db/mongo/models.py +++ b/mediagoblin/db/mongo/models.py @@ -282,10 +282,8 @@ class MediaEntry(Document): 'uploader': self.uploader, 'state': 'processed'}).sort( '_id', ASCENDING).limit(1) - if cursor.count(): - return urlgen('mediagoblin.user_pages.media_home', - user=self.get_uploader().username, - media=unicode(cursor[0].slug)) + for media in cursor: + return media.url_for_self(urlgen) def url_to_next(self, urlgen): """ @@ -296,10 +294,8 @@ class MediaEntry(Document): 'state': 'processed'}).sort( '_id', DESCENDING).limit(1) - if cursor.count(): - return urlgen('mediagoblin.user_pages.media_home', - user=self.get_uploader().username, - media=unicode(cursor[0].slug)) + for media in cursor: + return media.url_for_self(urlgen) def get_uploader(self): return self.db.User.find_one({'_id': self.uploader}) diff --git a/mediagoblin/templates/mediagoblin/user_pages/media.html b/mediagoblin/templates/mediagoblin/user_pages/media.html index c171dd5a..77461983 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/media.html +++ b/mediagoblin/templates/mediagoblin/user_pages/media.html @@ -135,10 +135,8 @@ {% endfor %} - {{ render_pagination(request, pagination, - request.urlgen('mediagoblin.user_pages.media_home', - user = media.get_uploader().username, - media = media._id)) }} + {{ render_pagination(request, pagination, + media.url_for_self(request.urlgen)) }} {% endif %}