media_confirm_delete: redirect to next, then prev, then user home
authorAlon Levy <alon@pobox.com>
Fri, 16 Aug 2013 08:23:22 +0000 (11:23 +0300)
committerRodney Ewing <ewing.rj@gmail.com>
Sat, 17 Aug 2013 16:44:02 +0000 (09:44 -0700)
Instead of redirecting directly to user's home. Makes the flow for mass or just
a few deletions easier. For really large deletions it would still make sense to
have a dedicated view, but this is still way better then losing context by
jumping back to the home view.

Signed-off-by: Alon Levy <alon@pobox.com>
mediagoblin/user_pages/views.py

index 91ea04b8ffd7fbb02e53cad67a40454a632d8f07..9d3cb08b5b58e09bf552dc85b72890ec332d748c 100644 (file)
@@ -301,8 +301,12 @@ def media_confirm_delete(request, media):
             messages.add_message(
                 request, messages.SUCCESS, _('You deleted the media.'))
 
-            return redirect(request, "mediagoblin.user_pages.user_home",
-                user=username)
+            location = media.url_to_next(request.urlgen)
+            if not location:
+                location=media.url_to_prev(request.urlgen)
+            if not location:
+                location="mediagoblin.user_pages.user_home"
+            return redirect(request, location=location, user=username)
         else:
             messages.add_message(
                 request, messages.ERROR,