from webob import exc
-from mediagoblin.util import render_to_response
+from mediagoblin.util import render_to_response, redirect
from mediagoblin.db.util import ObjectId
from mediagoblin.auth import lib as auth_lib
from mediagoblin.auth import forms as auth_forms
send_verification_email(entry, request)
- # Redirect to register_success
- return exc.HTTPFound(
- location=request.urlgen("mediagoblin.auth.register_success"))
+ return redirect(request, "mediagoblin.auth.register_success")
return render_to_response(request,
'mediagoblin/auth/register.html',
if request.POST.get('next'):
return exc.HTTPFound(location=request.POST['next'])
else:
- return exc.HTTPFound(
- location=request.urlgen("index"))
+ return redirect(request, "index")
else:
# Prevent detecting who's on this system by testing login
# Maybe deleting the user_id parameter would be enough?
request.session.delete()
- return exc.HTTPFound(
- location=request.urlgen("index"))
+ return redirect(request, "index")
def verify_email(request):
send_verification_email(request.user, request)
- return exc.HTTPFound(
- location=request.urlgen('mediagoblin.auth.resend_verification_success'))
+ return redirect(request, 'mediagoblin.auth.resend_verification_success')
def resend_activation_success(request):
from bson.errors import InvalidId
from webob import exc
+from mediagoblin.util import redirect
from mediagoblin.db.util import ObjectId
def new_controller_func(request, *args, **kwargs):
if request.user and \
request.user.get('status') == u'needs_email_verification':
- return exc.HTTPFound(
- location = request.urlgen(
- 'mediagoblin.auth.verify_email_notice'))
+ return redirect(request,
+ 'mediagoblin.auth.verify_email_notice')
elif not request.user or request.user.get('status') != u'active':
return exc.HTTPFound(
location="%s?next=%s" % (
from webob import exc
-from mediagoblin.util import render_to_response
+from mediagoblin.util import render_to_response, redirect
from mediagoblin.edit import forms
from mediagoblin.edit.lib import may_edit_media
from mediagoblin.decorators import require_active_login, get_user_media_entry
media['slug'] = request.POST['slug']
media.save()
- # redirect
- return exc.HTTPFound(
- location=request.urlgen("mediagoblin.user_pages.media_home",
- user=media.uploader()['username'], media=media['slug']))
+ return redirect(request, "mediagoblin.user_pages.media_home",
+ user=media.uploader()['username'], media=media['slug'])
return render_to_response(request,
'mediagoblin/edit/edit.html',
from os.path import splitext
from cgi import FieldStorage
-from webob import exc
from werkzeug.utils import secure_filename
-from mediagoblin.util import render_to_response
+from mediagoblin.util import render_to_response, redirect
from mediagoblin.decorators import require_active_login
from mediagoblin.submit import forms as submit_forms
from mediagoblin.process_media import process_media_initial
# queue it for processing
process_media_initial.delay(unicode(entry['_id']))
- # redirect
- return exc.HTTPFound(
- location=request.urlgen("mediagoblin.submit.success"))
+ return redirect(request, "mediagoblin.submit.success")
return render_to_response(request,
'mediagoblin/submit/start.html',
import jinja2
import translitcodec
from paste.deploy.loadwsgi import NicerConfigParser
-from webob import Response
+from webob import Response, exc
from mediagoblin import globals as mgoblin_globals
from mediagoblin.db.util import ObjectId
return Response(render_template(request, template, context))
+def redirect(request, *args, **kwargs):
+ """Returns a HTTPFound(), takes a request and then urlgen params"""
+ return exc.HTTPFound(location=request.urlgen(*args, **kwargs))
+
+
def setup_user_in_request(request):
"""
Examine a request and tack on a request.user parameter if that's