From 8d7b549bb6d17c66ce1d3590da6e9bd0868b4403 Mon Sep 17 00:00:00 2001 From: Elrond Date: Fri, 9 Sep 2011 23:59:32 +0200 Subject: [PATCH] Use media.url_for_self() instead of generating it Some places used to generate the URL for a media entry on their own instead of calling media.url_for_self() to do that. The later handles missing slugs better. --- mediagoblin/edit/views.py | 9 ++++----- mediagoblin/user_pages/views.py | 5 ++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/mediagoblin/edit/views.py b/mediagoblin/edit/views.py index 11bee110..15edfdd6 100644 --- a/mediagoblin/edit/views.py +++ b/mediagoblin/edit/views.py @@ -73,8 +73,8 @@ def edit_media(request, media): media['slug'] = unicode(request.POST['slug']) media.save() - return redirect(request, "mediagoblin.user_pages.media_home", - user=media.uploader()['username'], media=media['slug']) + return exc.HTTPFound( + location=media.url_for_self(request.urlgen)) if request.user['is_admin'] \ and media['uploader'] != request.user['_id'] \ @@ -130,9 +130,8 @@ def edit_attachments(request, media): % (request.POST['attachment_name'] or request.POST['attachment_file'].filename)) - return redirect(request, 'mediagoblin.user_pages.media_home', - user=media.uploader()['username'], - media=media['slug']) + return exc.HTTPFound( + location=media.url_for_self(request.urlgen)) return render_to_response( request, 'mediagoblin/edit/attachments.html', diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py index f60bd186..6a82d718 100644 --- a/mediagoblin/user_pages/views.py +++ b/mediagoblin/user_pages/views.py @@ -165,9 +165,8 @@ def media_confirm_delete(request, media): return redirect(request, "mediagoblin.user_pages.user_home", user=username) else: - return redirect(request, "mediagoblin.user_pages.media_home", - user=media.uploader()['username'], - media=media['slug']) + return exc.HTTPFound( + location=media.url_for_self(request.urlgen)) if ((request.user[u'is_admin'] and request.user[u'_id'] != media.uploader()[u'_id'])): -- 2.25.1