Ejemplo n.º 1
0
    def get_paths(self):

        paths = []
        for lang_code, lang_name in settings.LANGUAGES:
            # posts
            activate(lang_code)
            items = Post.objects.filter(
                is_published=True, language=lang_code).order_by('-pubdate')

            paths.extend([i.get_absolute_url() for i in items])

            paths.append(i18n_reverse(lang_code, 'blog_archive'))
            paths.append(i18n_reverse(lang_code, 'blog_feed'))

        return paths
Ejemplo n.º 2
0
    def get_paths(self):

        paths = []
        for lang_code, lang_name in settings.LANGUAGES:
            # posts
            activate(lang_code)
            items = Post.objects.filter(
                is_published=True, language=lang_code).order_by('-pubdate')

            paths.extend([i.get_absolute_url() for i in items])

            paths.append(i18n_reverse(lang_code, 'blog_archive'))
            paths.append(i18n_reverse(lang_code, 'blog_feed'))

        return paths
Ejemplo n.º 3
0
    def get_paths(self):

        paths = []
        for lang_code, lang_name in settings.LANGUAGES:
            activate(lang_code)
            items = list(
                I18NTag.objects.filter(language=lang_code).order_by('name'))

            paths.extend([i.get_absolute_url() for i in items])

            for tag in items:
                paths.append(i18n_reverse(lang_code, 'blog_tag_feed',
                             kwargs={'slug': tag.slug_no_locale}))

            paths.append(i18n_reverse(lang_code, 'blog_tags'))

        return paths
Ejemplo n.º 4
0
    def get_paths(self):

        paths = []
        for lang_code, lang_name in settings.LANGUAGES:
            activate(lang_code)
            items = list(
                I18NTag.objects.filter(language=lang_code).order_by('name'))

            paths.extend([i.get_absolute_url() for i in items])

            for tag in items:
                paths.append(
                    i18n_reverse(lang_code,
                                 'blog_tag_feed',
                                 kwargs={'slug': tag.slug_no_locale}))

            paths.append(i18n_reverse(lang_code, 'blog_tags'))

        return paths
Ejemplo n.º 5
0
    def render(self, context):
        from django.core.urlresolvers import NoReverseMatch
        from statirator.core.utils import i18n_reverse

        args = [arg.resolve(context) for arg in self.args]
        kwargs = dict([(smart_str(k, 'ascii'), v.resolve(context))
                       for k, v in self.kwargs.items()])

        language = self.language.resolve(context)

        view_name = self.view_name
        if not self.legacy_view_name:
            view_name = view_name.resolve(context)

        # Try to look up the URL twice: once given the view name, and again
        # relative to what we guess is the "main" app. If they both fail,
        # re-raise the NoReverseMatch unless we're using the
        # {% url ... as var %} construct in which cause return nothing.
        url = ''
        try:
            url = i18n_reverse(language, view_name, args=args, kwargs=kwargs,
                               current_app=context.current_app)
        except NoReverseMatch, e:
            if settings.SETTINGS_MODULE:
                project_name = settings.SETTINGS_MODULE.split('.')[0]
                try:
                    url = i18n_reverse(
                        language, project_name + '.' + view_name,
                        args=args, kwargs=kwargs,
                        current_app=context.current_app)
                except NoReverseMatch:
                    if self.asvar is None:
                        # Re-raise the original exception, not the one with
                        # the path relative to the project. This makes a
                        # better error message.
                        raise e
            else:
                if self.asvar is None:
                    raise e
Ejemplo n.º 6
0
 def link(self):
     return i18n_reverse(self.language_code, 'blog_archive')
Ejemplo n.º 7
0
 def link(self):
     return i18n_reverse(self.language_code, 'blog_archive')