From 2e6ee596ad9dbc794979069f2f14b856db02343b Mon Sep 17 00:00:00 2001 From: Elrond Date: Sun, 28 Apr 2013 00:14:50 +0200 Subject: Create redir_obj and use it around. This is a shortcut function to redirect to the main page for an object. Objects currently supported: media entries and collections. And go around and replace various places to use this. --- mediagoblin/edit/views.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'mediagoblin/edit/views.py') diff --git a/mediagoblin/edit/views.py b/mediagoblin/edit/views.py index 34b7aaca..bfcf65b5 100644 --- a/mediagoblin/edit/views.py +++ b/mediagoblin/edit/views.py @@ -28,7 +28,8 @@ from mediagoblin.edit.lib import may_edit_media from mediagoblin.decorators import (require_active_login, active_user_from_url, get_media_entry_by_id, user_may_alter_collection, get_user_collection) -from mediagoblin.tools.response import render_to_response, redirect +from mediagoblin.tools.response import render_to_response, \ + redirect, redirect_obj from mediagoblin.tools.translate import pass_to_ugettext as _ from mediagoblin.tools.text import ( convert_to_tag_list_of_dicts, media_tags_as_string) @@ -74,8 +75,7 @@ def edit_media(request, media): media.slug = slug media.save() - return redirect(request, - location=media.url_for_self(request.urlgen)) + return redirect_obj(request, media) if request.user.is_admin \ and media.uploader != request.user.id \ @@ -331,9 +331,7 @@ def edit_collection(request, collection): collection.save() - return redirect(request, "mediagoblin.user_pages.user_collection", - user=collection.get_creator.username, - collection=collection.slug) + return redirect_obj(request, collection) if request.user.is_admin \ and collection.creator != request.user.id \ -- cgit v1.2.3