summaryrefslogtreecommitdiff
path: root/app/lib/django_comments_old/views/utils.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2017-10-14 11:36:20 -0500
committerluxagraf <sng@luxagraf.net>2017-10-14 11:36:20 -0500
commitbd1adb4927695ed0ce3ac94d90c68bd61e440275 (patch)
treef014fa16a64eb55e62ecb92c62a4e8186cd318a4 /app/lib/django_comments_old/views/utils.py
parentcbadfff80be33b4ec67da57585451884c6378380 (diff)
updated comments app and added caption to photo list view
Diffstat (limited to 'app/lib/django_comments_old/views/utils.py')
-rw-r--r--app/lib/django_comments_old/views/utils.py71
1 files changed, 0 insertions, 71 deletions
diff --git a/app/lib/django_comments_old/views/utils.py b/app/lib/django_comments_old/views/utils.py
deleted file mode 100644
index 314ab8c..0000000
--- a/app/lib/django_comments_old/views/utils.py
+++ /dev/null
@@ -1,71 +0,0 @@
-"""
-A few bits of helper functions for comment views.
-"""
-
-import textwrap
-try:
- from urllib.parse import urlencode
-except ImportError: # Python 2
- from urllib import urlencode
-
-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.utils.http import is_safe_url
-
-import django_comments
-
-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 = ('?' in next) and '&' or '?'
- 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 = django_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