зеркало из https://github.com/mozilla/kitsune.git
Document.get_absolute_url() now uses reverse
This commit is contained in:
Родитель
e32749d76b
Коммит
f415ad8ce4
|
@ -32,13 +32,19 @@ def reverse(viewname, urlconf=None, args=None, kwargs=None, prefix=None,
|
|||
unprefixed URL, it is probably easier to substitute LocalizingClient
|
||||
for any uses of django.test.client.Client and forgo this kwarg.
|
||||
|
||||
locale -- By default, reverse prepends the current locale (if set) or
|
||||
the default locale if force_locale == True. To override this behavior
|
||||
and have it prepend a different locale, pass in the locale parameter
|
||||
with the desired locale. When passing a locale, the force_locale is
|
||||
not used and is implicitly True.
|
||||
|
||||
"""
|
||||
if locale:
|
||||
prefixer = Prefixer(locale=locale)
|
||||
else:
|
||||
prefixer = get_url_prefixer()
|
||||
if not prefixer and force_locale:
|
||||
prefixer = Prefixer()
|
||||
if not prefixer and force_locale:
|
||||
prefixer = Prefixer()
|
||||
|
||||
if prefixer:
|
||||
prefix = prefix or '/'
|
||||
|
|
|
@ -5,10 +5,10 @@ from tower import ugettext_lazy as _lazy
|
|||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
from django.utils.http import urlquote
|
||||
|
||||
from sumo.models import ModelBase, TaggableMixin
|
||||
from sumo.utils import wiki_to_html
|
||||
from sumo.urlresolvers import reverse
|
||||
|
||||
|
||||
# Disruptiveness of edits to translated versions. Keys indicate the relative
|
||||
|
@ -112,7 +112,7 @@ class Document(ModelBase, TaggableMixin):
|
|||
operating_systems = _inherited('operating_systems', 'operating_system_set')
|
||||
|
||||
def get_absolute_url(self):
|
||||
return '/%s/kb/%s' % (self.locale, urlquote(self.slug))
|
||||
return reverse('wiki.document', locale=self.locale, args=[self.slug])
|
||||
|
||||
def __unicode__(self):
|
||||
return '[%s] %s' % (self.locale, self.title)
|
||||
|
|
Загрузка…
Ссылка в новой задаче