Ejemplo n.º 1
0
    def post_process_urls(self, urlpatterns):
        """
        Customise URL patterns.

        This method allows decorators to be wrapped around an apps URL
        patterns.

        By default, this only allows custom decorators to be specified, but you
        could override this method to do anything you want.

        Args:
            urlpatterns (list): A list of URL patterns

        """
        # Test if this the URLs in the Application instance should be
        # available.  If the feature is hidden then we don't include the URLs.
        if feature_hidden(self.hidable_feature_name):
            return []

        for pattern in urlpatterns:
            if hasattr(pattern, 'url_patterns'):
                self.post_process_urls(pattern.url_patterns)

            if isinstance(pattern, URLPattern):
                # Apply the custom view decorator (if any) set for this class if this
                # is a URL Pattern.
                decorator = self.get_url_decorator(pattern)
                if decorator:
                    pattern.callback = decorator(pattern.callback)

        return urlpatterns
Ejemplo n.º 2
0
    def post_process_urls(self, urlpatterns):
        """
        Customise URL patterns.

        This method allows decorators to be wrapped around an apps URL
        patterns.

        By default, this only allows custom decorators to be specified, but you
        could override this method to do anything you want.

        Args:
            urlpatterns (list): A list of URL patterns

        """
        # Test if this the URLs in the Application instance should be
        # available.  If the feature is hidden then we don't include the URLs.
        if feature_hidden(self.hidable_feature_name):
            return patterns('')

        for pattern in urlpatterns:
            if hasattr(pattern, 'url_patterns'):
                self.post_process_urls(pattern.url_patterns)
            if not hasattr(pattern, '_callback'):
                continue
            # Look for a custom decorator
            decorator = self.get_url_decorator(pattern)
            if decorator:
                # Nasty way of modifying a RegexURLPattern
                pattern._callback = decorator(pattern._callback)
        return urlpatterns
Ejemplo n.º 3
0
    def post_process_urls(self, urlpatterns):
        """
        Customise URL patterns.

        This method allows decorators to be wrapped around an apps URL
        patterns.

        By default, this only allows custom decorators to be specified, but you
        could override this method to do anything you want.

        Args:
            urlpatterns (list): A list of URL patterns

        """
        # Test if this the URLs in the Application instance should be
        # available.  If the feature is hidden then we don't include the URLs.
        if feature_hidden(self.hidable_feature_name):
            return []

        for pattern in urlpatterns:
            if hasattr(pattern, 'url_patterns'):
                self.post_process_urls(pattern.url_patterns)

            if isinstance(pattern, URLPattern):
                # Apply the custom view decorator (if any) set for this class if this
                # is a URL Pattern.
                decorator = self.get_url_decorator(pattern)
                if decorator:
                    pattern.callback = decorator(pattern.callback)

        return urlpatterns
Ejemplo n.º 4
0
 def get_sort_choices(self):
     choices = super().get_sort_choices()
     if feature_hidden("reviews"):
         return [(key, value) for (key, value) in choices
                 if key != self.TOP_RATED]
     else:
         return choices
Ejemplo n.º 5
0
    def post_process_urls(self, urlpatterns):
        """
        Customise URL patterns.

        This method allows decorators to be wrapped around an apps URL
        patterns.

        By default, this only allows custom decorators to be specified, but you
        could override this method to do anything you want.

        Args:
            urlpatterns (list): A list of URL patterns

        """
        # Test if this the URLs in the Application instance should be
        # available.  If the feature is hidden then we don't include the URLs.
        if feature_hidden(self.hidable_feature_name):
            return []

        for pattern in urlpatterns:
            if hasattr(pattern, 'url_patterns'):
                self.post_process_urls(pattern.url_patterns)

            # In Django 1.8 and 1.9 we could distinguish the RegexURLPattern
            # by simply checking if the pattern has a `_callback` attribute.
            # In 1.10 this attribute is now only available as `callback`.
            # Since the `callback` attribute is also available on patterns we
            # should not modify (`RegexURLResolver`) we just do a isinstance()
            # check here.
            if DJANGO_VERSION < (1, 10):
                if not hasattr(pattern, '_callback'):
                    continue
                # Look for a custom decorator
                decorator = self.get_url_decorator(pattern)
                if decorator:
                    # Nasty way of modifying a RegexURLPattern
                    pattern._callback = decorator(pattern._callback)
            else:
                if isinstance(pattern, RegexURLPattern):
                    # Look for a custom decorator
                    decorator = self.get_url_decorator(pattern)
                    if decorator:
                        pattern.callback = decorator(pattern.callback)

        return urlpatterns
Ejemplo n.º 6
0
    def post_process_urls(self, urlpatterns):
        """
        Customise URL patterns.

        This method allows decorators to be wrapped around an apps URL
        patterns.

        By default, this only allows custom decorators to be specified, but you
        could override this method to do anything you want.

        Args:
            urlpatterns (list): A list of URL patterns

        自定义URL模式。
        此方法允许装饰器包裹应用程序URL模式。
        默认情况下,这只允许指定自定义装饰器,但您可以覆盖此方法以执行任何操作。
        Args:
            urlpatterns(list):URL模式列表
        """
        # Test if this the URLs in the Application instance should be
        # available.  If the feature is hidden then we don't include the URLs.
        # 测试应用程序实例中的URL是否可用。 如果隐藏该功能,则我们不会包含这些网址。
        if feature_hidden(self.hidable_feature_name):
            return []

        for pattern in urlpatterns:
            if hasattr(pattern, 'url_patterns'):
                self.post_process_urls(pattern.url_patterns)

            if isinstance(pattern, URLPattern):
                # Apply the custom view decorator (if any) set for this class if this
                # is a URL Pattern.
                # 如果这是一个URL模式,则应用为此类设置的自定义视图装饰器(如果有)。
                decorator = self.get_url_decorator(pattern)
                if decorator:
                    pattern.callback = decorator(pattern.callback)

        return urlpatterns
Ejemplo n.º 7
0
 def render(self, context):
     if not feature_hidden(self.feature_name):
         output = self.nodelist.render(context)
         return output
     else:
         return ''
Ejemplo n.º 8
0
 def render(self, context):
     if not feature_hidden(self.feature_name):
         output = self.nodelist.render(context)
         return output
     else:
         return ''