diff options
Diffstat (limited to 'lib/python2.7/site-packages/django/contrib/comments/views/utils.py')
-rw-r--r-- | lib/python2.7/site-packages/django/contrib/comments/views/utils.py | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/lib/python2.7/site-packages/django/contrib/comments/views/utils.py b/lib/python2.7/site-packages/django/contrib/comments/views/utils.py deleted file mode 100644 index 3705b7e..0000000 --- a/lib/python2.7/site-packages/django/contrib/comments/views/utils.py +++ /dev/null @@ -1,67 +0,0 @@ -""" -A few bits of helper functions for comment views. -""" - -import textwrap - -from django.http import HttpResponseRedirect -from django.shortcuts import render_to_response, resolve_url -from django.template import RequestContext -from django.core.exceptions import ObjectDoesNotExist -from django.contrib import comments -from django.utils.http import is_safe_url -from django.utils.six.moves.urllib.parse import urlencode - -def next_redirect(request, fallback, **get_kwargs): - """ - Handle the "where should I go next?" part of comment views. - - The next value could be a - ``?next=...`` GET arg or the URL of a given view (``fallback``). See - the view modules for examples. - - Returns an ``HttpResponseRedirect``. - """ - next = request.POST.get('next') - if not is_safe_url(url=next, host=request.get_host()): - next = resolve_url(fallback) - - if get_kwargs: - if '#' in next: - tmp = next.rsplit('#', 1) - next = tmp[0] - anchor = '#' + tmp[1] - else: - anchor = '' - - joiner = '&' if '?' in next else '?' - next += joiner + urlencode(get_kwargs) + anchor - return HttpResponseRedirect(next) - -def confirmation_view(template, doc="Display a confirmation view."): - """ - Confirmation view generator for the "comment was - posted/flagged/deleted/approved" views. - """ - def confirmed(request): - comment = None - if 'c' in request.GET: - try: - comment = comments.get_model().objects.get(pk=request.GET['c']) - except (ObjectDoesNotExist, ValueError): - pass - return render_to_response(template, - {'comment': comment}, - context_instance=RequestContext(request) - ) - - confirmed.__doc__ = textwrap.dedent("""\ - %s - - Templates: :template:`%s`` - Context: - comment - The posted comment - """ % (doc, template) - ) - return confirmed |