コード例 #1
0
ファイル: sites.py プロジェクト: mpetyx/mpetyx.com
    def root(self, request, url):
        """
        DEPRECATED. This function is the old way of handling URL resolution, and
        is deprecated in favor of real URL resolution -- see ``get_urls()``.

        This function still exists for backwards-compatibility; it will be
        removed in Django 1.3.
        """
        import warnings

        warnings.warn(
            "AdminSite.root() is deprecated; use include(admin.site.urls) instead.",
            DeprecationWarning
        )

        #
        # Again, remember that the following only exists for
        # backwards-compatibility. Any new URLs, changes to existing URLs, or
        # whatever need to be done up in get_urls(), above!
        #

        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 "View on site" links.
        elif url.startswith('r/'):
            from django.contrib.contenttypes.views 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.')
コード例 #2
0
ファイル: sites.py プロジェクト: Normatica/django-11599
    def root(self, request, url):
        """
        DEPRECATED. This function is the old way of handling URL resolution, and
        is deprecated in favor of real URL resolution -- see ``get_urls()``.

        This function still exists for backwards-compatibility; it will be
        removed in Django 1.3.
        """
        import warnings
        warnings.warn(
            "AdminSite.root() is deprecated; use include(admin.site.urls) instead.",
            PendingDeprecationWarning
        )

        #
        # Again, remember that the following only exists for
        # backwards-compatibility. Any new URLs, changes to existing URLs, or
        # whatever need to be done up in get_urls(), above!
        #

        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 "View on site" links.
        elif url.startswith('r/'):
            from django.contrib.contenttypes.views 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.')
コード例 #3
0
ファイル: views.py プロジェクト: MechanisM/smartmin
def smart_url(url, id=None):
    """
    URLs that start with @ are reversed, using the passed in arguments.

    Otherwise a straight % substitution is applied.
    """
    if url.find("@") >= 0:
        (args, value) = url.split('@')

        if args:
            return reverse(value, args=[id])
        else:
            return reverse(value)
    else:
        return url % id
コード例 #4
0
def smart_url(url, id=None):
    """
    URLs that start with @ are reversed, using the passed in arguments.

    Otherwise a straight % substitution is applied.
    """
    if url.find("@") >= 0:
        (args, value) = url.split('@')

        if args:
            return reverse(value, args=[id])
        else:
            return reverse(value)
    else:
        return url % id