From de12b4e77358a496bced68cbdc23bf50f95c7ee0 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Sat, 20 Aug 2011 15:57:24 -0500 Subject: [PATCH] Use render_404 EVERYWHERE! --- mediagoblin/auth/views.py | 4 ++-- mediagoblin/decorators.py | 16 ++++++++-------- mediagoblin/user_pages/views.py | 15 ++++++++------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/mediagoblin/auth/views.py b/mediagoblin/auth/views.py index 9120196f..4c4a34fd 100644 --- a/mediagoblin/auth/views.py +++ b/mediagoblin/auth/views.py @@ -20,7 +20,7 @@ from webob import exc from mediagoblin import messages from mediagoblin import mg_globals -from mediagoblin.util import render_to_response, redirect +from mediagoblin.util import render_to_response, redirect, render_404 from mediagoblin.util import pass_to_ugettext as _ from mediagoblin.db.util import ObjectId from mediagoblin.auth import lib as auth_lib @@ -144,7 +144,7 @@ def verify_email(request): """ # If we don't have userid and token parameters, we can't do anything; 404 if not request.GET.has_key('userid') or not request.GET.has_key('token'): - return exc.HTTPNotFound() + return render_404(request) user = request.db.User.find_one( {'_id': ObjectId(unicode(request.GET['userid']))}) diff --git a/mediagoblin/decorators.py b/mediagoblin/decorators.py index 2e90274e..c66049ca 100644 --- a/mediagoblin/decorators.py +++ b/mediagoblin/decorators.py @@ -17,7 +17,7 @@ from webob import exc -from mediagoblin.util import redirect +from mediagoblin.util import redirect, render_404 from mediagoblin.db.util import ObjectId, InvalidId @@ -60,9 +60,9 @@ def uses_pagination(controller): try: page = int(request.GET.get('page', 1)) if page < 0: - return exc.HTTPNotFound() + return render_404(request) except ValueError: - return exc.HTTPNotFound() + return render_404(request) return controller(request, page=page, *args, **kwargs) @@ -78,7 +78,7 @@ def get_user_media_entry(controller): {'username': request.matchdict['user']}) if not user: - return exc.HTTPNotFound() + return render_404(request) media = request.db.MediaEntry.find_one( {'slug': request.matchdict['media'], @@ -93,11 +93,11 @@ def get_user_media_entry(controller): 'state': 'processed', 'uploader': user['_id']}) except InvalidId: - return exc.HTTPNotFound() + return render_404(request) # Still no media? Okay, 404. if not media: - return exc.HTTPNotFound() + return render_404(request) return controller(request, media=media, *args, **kwargs) @@ -113,11 +113,11 @@ def get_media_entry_by_id(controller): {'_id': ObjectId(request.matchdict['media']), 'state': 'processed'}) except InvalidId: - return exc.HTTPNotFound() + return render_404(request) # Still no media? Okay, 404. if not media: - return exc.HTTPNotFound() + return render_404(request) return controller(request, media=media, *args, **kwargs) diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py index d4ff1fce..3677c134 100644 --- a/mediagoblin/user_pages/views.py +++ b/mediagoblin/user_pages/views.py @@ -19,7 +19,8 @@ from webob import exc from mediagoblin import messages from mediagoblin.db.util import DESCENDING, ObjectId from mediagoblin.util import ( - Pagination, render_to_response, redirect, cleaned_markdown_conversion) + Pagination, render_to_response, redirect, cleaned_markdown_conversion, + render_404) from mediagoblin.user_pages import forms as user_forms from mediagoblin.decorators import (uses_pagination, get_user_media_entry, @@ -34,7 +35,7 @@ def user_home(request, page): user = request.db.User.find_one({ 'username': request.matchdict['user']}) if not user: - return exc.HTTPNotFound() + return render_404(request) elif user['status'] != u'active': return render_to_response( request, @@ -50,7 +51,7 @@ def user_home(request, page): #if no data is available, return NotFound if media_entries == None: - return exc.HTTPNotFound() + return render_404(request) user_gallery_url = request.urlgen( 'mediagoblin.user_pages.user_gallery', @@ -71,7 +72,7 @@ def user_gallery(request, page): 'username': request.matchdict['user'], 'status': 'active'}) if not user: - return exc.HTTPNotFound() + return render_404(request) cursor = request.db.MediaEntry.find( {'uploader': user['_id'], @@ -82,7 +83,7 @@ def user_gallery(request, page): #if no data is available, return NotFound if media_entries == None: - return exc.HTTPNotFound() + return render_404(request) return render_to_response( request, @@ -154,7 +155,7 @@ def atom_feed(request): 'username': request.matchdict['user'], 'status': 'active'}) if not user: - return exc.HTTPNotFound() + return render_404(request) cursor = request.db.MediaEntry.find({ 'uploader': user['_id'], @@ -190,7 +191,7 @@ def processing_panel(request): # Make sure the user exists and is active if not user: - return exc.HTTPNotFound() + return render_404(request) elif user['status'] != u'active': return render_to_response( request, -- 2.25.1