Changes between Version 26 and Version 27 of UsingFreeComment


Ignore:
Timestamp:
11/29/2007 04:31:45 PM (8 years ago)
Author:
Kellen
Comment:

New version of the redirect code; old version didn't work with previews, didn't fallback gracefully.

Legend:

Unmodified
Added
Removed
Modified
  • UsingFreeComment

    v26 v27  
    247247
    248248def my_post_free_comment(request):
    249     if request.POST.has_key('url'):
    250         url = request.POST['url']
    251     else:
    252         url = '/comments/posted.html'
    253     response = post_free_comment(request)
    254     return HttpResponseRedirect(url)
     249    if request.has_key('url') and not request.has_key('preview'):
     250        response = post_free_comment(request)
     251        # ensure there's a url to redirect to, and that post_free_comment worked
     252        if len(request['url'].strip()) > 0 and isinstance(response, HttpResponseRedirect):
     253            return redirect_to(request, request['url'])
     254        # fallback on the default post_free_comment response
     255        return response
     256    return post_free_comment(request)
    255257}}}
    256258
Back to Top