def unquoting_view(request, *args, **kwargs): if six.PY2: return view( request, *[ urllib_parse.unquote( six.binary_type(value)).decode("utf-8") for value in args ], **dict((key, urllib_parse.unquote(six.binary_type( value)).decode("utf-8")) for key, value in kwargs.items())) return view( request, *[urllib_parse.unquote(value) for value in args], **dict((key, urllib_parse.unquote(value)) for key, value in kwargs.items()))
def should_setup_login_session(self, request): """ Only set self.LOGIN_SESSION_KEY in the session when the request - has LOGIN_STRING (defaults to @fiber) behind its request-url """ qs = unquote(request.META.get('QUERY_STRING', '')) return request.path_info.endswith(LOGIN_STRING) or qs.endswith(LOGIN_STRING)
def setup_login_session(self, request): """ Add self.LOGIN_SESSION_KEY to the session and redirect to the the requested path without LOGIN_STRING """ request.session[self.LOGIN_SESSION_KEY] = True url = request.path_info.replace(LOGIN_STRING, '') qs = unquote(request.META.get('QUERY_STRING', '')) if qs: qs = '?%s' % qs.replace(LOGIN_STRING, '').rstrip('&') return HttpResponseRedirect(''.join([url, qs]))
def get_service_url(request, redirect_to=None): """Generates application django service URL for CAS""" protocol = get_protocol(request) host = request.get_host() service = urllib_parse.urlunparse( (protocol, host, request.path, '', '', ''), ) if '?' in service: service += '&' else: service += '?' service += urllib_parse.unquote( urllib_parse.urlencode( {REDIRECT_FIELD_NAME: redirect_to or get_redirect_url(request)})) return service
def get_service_url(request, redirect_to=None): """Generates application django service URL for CAS""" protocol = get_protocol(request) host = request.get_host() service = urllib_parse.urlunparse( (protocol, host, request.path, '', '', ''), ) if '?' in service: service += '&' else: service += '?' service += urllib_parse.unquote(urllib_parse.urlencode({ REDIRECT_FIELD_NAME: redirect_to or get_redirect_url(request) })) return service
def slug(self): path = self.path() prefix = '/en-US/' assert path.startswith(prefix) return unquote(path[len(prefix):])