<s> """<STR_LIT>""" <EOL> import textwrap <EOL> try : <EOL> from urllib . parse import urlencode <EOL> except ImportError : <EOL> from urllib import urlencode <EOL> from django . http import HttpResponseRedirect <EOL> from django . shortcuts import render , resolve_url <EOL> from django . core . exceptions import ObjectDoesNotExist <EOL> from django . utils . http import is_safe_url <EOL> import django_comments <EOL> def next_redirect ( request , fallback , ** get_kwargs ) : <EOL> """<STR_LIT>""" <EOL> next = request . POST . get ( '<STR_LIT>' ) <EOL> if not is_safe_url ( url = next , host = request . get_host ( ) ) : <EOL> next = resolve_url ( fallback ) <EOL> if get_kwargs : <EOL> if '<STR_LIT:#>' in next : <EOL> tmp = next . rsplit ( '<STR_LIT:#>' , <NUM_LIT:1> ) <EOL> next = tmp [ <NUM_LIT:0> ] <EOL> anchor = '<STR_LIT:#>' + tmp [ <NUM_LIT:1> ] <EOL> else : <EOL> anchor = '<STR_LIT>' <EOL> joiner = ( '<STR_LIT:?>' in next ) and '<STR_LIT:&>' or '<STR_LIT:?>' <EOL> next += joiner + urlencode ( get_kwargs ) + anchor <EOL> return HttpResponseRedirect ( next ) <EOL> def confirmation_view ( template , doc = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> def confirmed ( request ) : <EOL> comment = None <EOL> if '<STR_LIT:c>' in request . GET : <EOL> try : <EOL> comment = django_comments . get_model ( ) . objects . get ( pk = request . GET [ '<STR_LIT:c>' ] ) <EOL> except ( ObjectDoesNotExist , ValueError ) : <EOL> pass <EOL> return render ( request , template , { '<STR_LIT>' : comment } ) <EOL> confirmed . __doc__ = textwrap . dedent ( """<STR_LIT>""" % ( doc , template ) <EOL> ) <EOL> return confirmed </s>
