Пример #1
0
    def process_response(self, request, response):
        group_url = re.match('^/group/(?P<id>\d+)-(?P<url>[-\w]+)/$',
                             request.path_info)
        if (response.status_code == 404 and group_url and
            (Group.objects.filter(url=group_url.group('url')).exists())):

            newurl = reverse('groups:show_group',
                             kwargs={'url': group_url.group('url')})
            if request.GET:
                with safe_query_string(request):
                    newurl += '?' + request.META['QUERY_STRING']
            return HttpResponseRedirect(newurl)
        return response
Пример #2
0
    def process_response(self, request, response):
        group_url = re.match('^/group/(?P<id>\d+)-(?P<url>[-\w]+)/$',
                             request.path_info)
        if (response.status_code == 404 and
                group_url and Group.objects.filter(url=group_url.group('url')).exists()):

            newurl = reverse('groups:show_group',
                             kwargs={'url': group_url.group('url')})
            if request.GET:
                with safe_query_string(request):
                    newurl += '?' + request.META['QUERY_STRING']
            return HttpResponseRedirect(newurl)
        return response
Пример #3
0
    def process_response(self, request, response):
        if (response.status_code == 404 and not
            request.path_info.startswith('/u/') and not
            is_valid_path(request.path_info) and
            User.objects.filter(username__iexact=request.path_info[1:].strip('/')).exists() and
            request.user.is_authenticated() and
                request.user.userprofile.is_vouched):

            newurl = '/u' + request.path_info
            if request.GET:
                with safe_query_string(request):
                    newurl += '?' + request.META['QUERY_STRING']
            return HttpResponseRedirect(newurl)
        return response
Пример #4
0
    def __call__(self, request):
        response = self.get_response(request)

        if (response.status_code == 404
                and not request.path_info.startswith("/u/")
                and not is_valid_path(request.path_info)
                and User.objects.filter(username__iexact=request.path_info[1:].
                                        strip("/")).exists()
                and request.user.is_authenticated
                and request.user.userprofile.is_vouched):

            newurl = "/u" + request.path_info
            if request.GET:
                with safe_query_string(request):
                    newurl += "?" + request.META["QUERY_STRING"]
            return HttpResponseRedirect(newurl)
        return response