예제 #1
0
 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()))
예제 #2
0
 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)
예제 #3
0
 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)
예제 #4
0
 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]))
예제 #5
0
 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]))
예제 #6
0
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
예제 #7
0
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
예제 #8
0
 def slug(self):
     path = self.path()
     prefix = '/en-US/'
     assert path.startswith(prefix)
     return unquote(path[len(prefix):])