Exemple #1
0
    def root(self, request, url):
        """ 
        Handles main URL routing for the admin app.

        `url` is the remainder of the URL -- e.g. 'comments/comment/'.
        """
        if request.method == 'GET' and not request.path.endswith('/'):
            return http.HttpResponseRedirect(request.path + '/')
        
        # Figure out the admin base URL path and stash it for later use
        self.root_path = re.sub(re.escape(url) + '$', '', request.path)
        
        url = url.rstrip('/') # Trim trailing slash, if it exists.

        # The 'logout' view doesn't require that the person is logged in.
        if url == 'logout':
            return self.logout(request)

        if not self.has_permission(request):
            response = self.login(request)
            if response:
                # make sure that there is a response before returning
                # this addresses any post data that might persist from
                # expired sessions and continue through (#5999)
                return response

        if url == '':
            return self.index(request)
        elif url == 'password_change':
            return self.password_change(request)
        elif url == 'password_change/done':
            return self.password_change_done(request)
        elif url == 'jsi18n':
            return self.i18n_javascript(request)
        # urls starting with 'r/' are for the "show in web" links
        elif url.startswith('r/'):
            from django.views.defaults import shortcut
            return shortcut(request, *url.split('/')[1:])
        else:
            match = USER_CHANGE_PASSWORD_URL_RE.match(url)
            if match:
                return self.user_change_password(request, match.group(1))
                
            if '/' in url:
                return self.model_page(request, *url.split('/', 2))

        raise http.Http404('The requested admin page does not exist.')
Exemple #2
0
    def root(self, request, url):
        """
        Handles main URL routing for the admin app.

        `url` is the remainder of the URL -- e.g. 'comments/comment/'.
        """
        if request.method == 'GET' and not request.path.endswith('/'):
            return http.HttpResponseRedirect(request.path + '/')
        
        if settings.DEBUG:
            self.check_dependencies()

        # Figure out the admin base URL path and stash it for later use
        self.root_path = re.sub(re.escape(url) + '$', '', request.path)

        url = url.rstrip('/') # Trim trailing slash, if it exists.

        # The 'logout' view doesn't require that the person is logged in.
        if url == 'logout':
            return self.logout(request)

        # Check permission to continue or display login form.
        if not self.has_permission(request):
            return self.login(request)

        if url == '':
            return self.index(request)
        elif url == 'password_change':
            return self.password_change(request)
        elif url == 'password_change/done':
            return self.password_change_done(request)
        elif url == 'jsi18n':
            return self.i18n_javascript(request)
        # urls starting with 'r/' are for the "show in web" links
        elif url.startswith('r/'):
            from django.views.defaults import shortcut
            return shortcut(request, *url.split('/')[1:])
        else:
            if '/' in url:
                return self.model_page(request, *url.split('/', 2))
            else:
                return self.app_index(request, url)

        raise http.Http404('The requested admin page does not exist.')
Exemple #3
0
    def root(self, request, url):
        """
        Handles main URL routing for the admin app.

        `url` is the remainder of the URL -- e.g. 'comments/comment/'.
        """
        url = url.rstrip("/")  # Trim trailing slash, if it exists.

        # The 'logout' view doesn't require that the person is logged in.
        if url == "logout":
            return self.logout(request)

        if not self.has_permission(request):
            return self.login(request)

        if url == "":
            return self.index(request)
        elif url == "password_change":
            return self.password_change(request)
        elif url == "password_change/done":
            return self.password_change_done(request)
        elif url == "jsi18n":
            return self.i18n_javascript(request)
        # urls starting with 'r/' are for the "show in web" links
        elif url.startswith("r/"):
            from django.views.defaults import shortcut

            return shortcut(request, *url.split("/")[1:])
        else:
            match = USER_CHANGE_PASSWORD_URL_RE.match(url)
            if match:
                return self.user_change_password(request, match.group(1))

            if "/" in url:
                return self.model_page(request, *url.split("/", 2))

        raise http.Http404("The requested admin page does not exist.")