Esempio n. 1
0
 def get_absolute_url(self):
     return translation_reverse(
         'newsletters_detail_html',
         args=[
             self.type.slug, self.id if self.is_source() else self.source.id
         ],
         lang=self.lang)
def _revid(t, extra=''):
    str = 'thisismymagic99substring'
    rev = translation_reverse('releases_detail',
                              args=[str],
                              lang=translation.get_language())
    rev = rev.replace(str, t)
    return '%s<a href="%s">%s</a>' % (extra, rev, t)
    def render(self, context):
        from django.urls import reverse, NoReverseMatch
        from djangoplicity.translation.models import translation_reverse

        args = [arg.resolve(context) for arg in self.args]
        kwargs = {
            force_text(k, 'ascii'): v.resolve(context)
            for k, v in self.kwargs.items()
        }
        view_name = self.view_name.resolve(context)
        try:
            current_app = context.request.current_app
        except AttributeError:
            try:
                current_app = context.request.resolver_match.namespace
            except AttributeError:
                current_app = None
        # Try to look up the URL. If it fails, raise NoReverseMatch unless the
        # {% url ... as var %} construct is used, in which case return nothing.
        url = ''
        try:
            url = reverse(view_name,
                          args=args,
                          kwargs=kwargs,
                          current_app=current_app)
            url = translation_reverse(view_name,
                                      args=args,
                                      kwargs=kwargs,
                                      current_app=current_app,
                                      lang=translation.get_language())
        except NoReverseMatch:
            if self.asvar is None:
                raise

        if self.asvar:
            context[self.asvar] = url
            return ''
        else:
            if context.autoescape:
                url = conditional_escape(url)
            return url
Esempio n. 4
0
 def get_absolute_url(self):
     return translation_reverse(
         'releases_detail_kids',
         args=[str(self.id if self.is_source() else self.source.id)],
         lang=self.lang)
Esempio n. 5
0
 def get_absolute_url(self):
     return translation_reverse( 'imagecomparisons_detail', args=[str( self.id if self.is_source() else self.source.id )], lang=self.lang )
Esempio n. 6
0
 def get_absolute_url(self):
     lang = translation.get_language()
     return translation_reverse('newsletters_defaultquery',
                                args=[self.slug],
                                lang=lang)
Esempio n. 7
0
 def get_absolute_url(self):
     return translation_reverse(
         'announcements_detail',
         args=[str(self.id if self.is_source() else self.source.id)],
         lang=self.lang)