Renamed get_absolute_url to get_url_path, but also assigned it in order to maintain compatibility with django.contrib apps.
This commit is contained in:
Родитель
c7963aee89
Коммит
69db7f68e5
|
@ -194,16 +194,16 @@ class Addon(amo.models.ModelBase):
|
|||
def __unicode__(self):
|
||||
return '%s: %s' % (self.id, self.name)
|
||||
|
||||
def get_absolute_url(self):
|
||||
def get_url_path(self):
|
||||
return reverse('addons.detail', args=(self.id,))
|
||||
|
||||
@property
|
||||
def meet_developers_url(self):
|
||||
return self.get_absolute_url() + 'developers'
|
||||
return self.get_url_path() + 'developers'
|
||||
|
||||
@property
|
||||
def reviews_url(self):
|
||||
return self.get_absolute_url() + 'reviews'
|
||||
return self.get_url_path() + 'reviews'
|
||||
|
||||
@classmethod
|
||||
def get_fallback(cls):
|
||||
|
@ -407,7 +407,7 @@ class Category(amo.models.ModelBase):
|
|||
def __unicode__(self):
|
||||
return unicode(self.name)
|
||||
|
||||
def get_absolute_url(self):
|
||||
def get_url_path(self):
|
||||
# TODO(jbalogh): reverse the real urls
|
||||
base = reverse('home')
|
||||
return '%sbrowse/type:%s/cat:%s' % (base, self.type_id, self.id)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% for addon in addons %}
|
||||
<div class="item {{ addon|statusflags }}">
|
||||
<h4>
|
||||
<a href="{{ addon.get_absolute_url() }}">{{ addon.name }}</a>
|
||||
<a href="{{ addon.get_url_path() }}">{{ addon.name }}</a>
|
||||
<span>
|
||||
{% trans users=addon.listed_authors|users_list %}
|
||||
created by {{ users }}
|
||||
|
@ -42,13 +42,13 @@
|
|||
{{ addon|reviews_link }}
|
||||
</p>
|
||||
</div>{# /item-info #}
|
||||
<a href="{{ addon.get_absolute_url() }}">
|
||||
<a href="{{ addon.get_url_path() }}">
|
||||
<img class="icon" alt="" src="{{ addon.icon_url }}" />
|
||||
</a>
|
||||
<blockquote>
|
||||
<p>{{ addon.summary }}</p>
|
||||
<p>
|
||||
<a href="{{ addon.get_absolute_url() }}">{{ _('Learn More') }}</a>
|
||||
<a href="{{ addon.get_url_path() }}">{{ _('Learn More') }}</a>
|
||||
</p>
|
||||
{# TODO publisher comment for collections
|
||||
if (!empty($a['comment'])) {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<tr>
|
||||
<td><input type="checkbox" name="addon_id" value="{{ addon.id }}"></td>
|
||||
<td>
|
||||
<a href="{{ addon.get_absolute_url() }}">{{ addon.name }}</a>
|
||||
<a href="{{ addon.get_url_path() }}">{{ addon.name }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{% if addon.version %}
|
||||
|
|
|
@ -27,7 +27,7 @@ def global_settings(request):
|
|||
if request.user.is_authenticated():
|
||||
link = {}
|
||||
link['text'] = _('View Profile')
|
||||
link['href'] = request.user.get_profile().get_absolute_url()
|
||||
link['href'] = request.user.get_profile().get_url_path()
|
||||
account_links.append(link)
|
||||
|
||||
link = {}
|
||||
|
|
|
@ -25,3 +25,6 @@ class ModelBase(caching.base.CachingMixin, TranslatedFieldMixin, models.Model):
|
|||
class Meta:
|
||||
abstract = True
|
||||
get_latest_by = 'created'
|
||||
|
||||
def get_absolute_url(self, *args, **kwargs):
|
||||
return self.get_url_path(*args, **kwargs)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
{% if api_version >= 1.5 %}
|
||||
<author>
|
||||
<name>{{ author.display_name }}</name>
|
||||
<link>{{ settings.SITE_URL + author.get_absolute_url() + '?src=api' }}</link>
|
||||
<link>{{ settings.SITE_URL + author.get_url_path() + '?src=api' }}</link>
|
||||
</author>
|
||||
{% else %}
|
||||
<author>{{ author.display_name }}</author>
|
||||
|
@ -46,12 +46,12 @@
|
|||
<thumbnail>{{ addon.thumbnail_url }}</thumbnail>
|
||||
<rating>{{ addon.bayesian_rating|wround(0, 'ceil') }}</rating>
|
||||
<learnmore>
|
||||
{{ settings.SITE_URL+addon.get_absolute_url()+'?src=api' }}</learnmore>
|
||||
{{ settings.SITE_URL+addon.get_url_path()+'?src=api' }}</learnmore>
|
||||
{% if addon.current_version %}
|
||||
{% for file in addon.current_version.files.all() %}
|
||||
<install hash="{{ file.hash }}" os="{{ file.platform.name }}"
|
||||
size="{{ file.size }}" units="kb">
|
||||
{{ file.get_absolute_url('api') }}
|
||||
{{ file.get_url_path('api') }}
|
||||
</install>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
|
|
@ -35,7 +35,7 @@ class Collection(amo.models.ModelBase):
|
|||
class Meta(amo.models.ModelBase.Meta):
|
||||
db_table = 'collections'
|
||||
|
||||
def get_absolute_url(self):
|
||||
def get_url_path(self):
|
||||
return '/collection/%s' % self.url_slug
|
||||
|
||||
@property
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
{% for collection in collections: %}
|
||||
<li>
|
||||
{# TODO reverse url #}
|
||||
<a class="collection" href="{{ collection.get_absolute_url() }}">
|
||||
<a class="collection" href="{{ collection.get_url_path() }}">
|
||||
{{ collection.name }}
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -74,11 +74,11 @@
|
|||
{% endif %} class="{{ addon|statusflags }}">
|
||||
<div class="inner">
|
||||
{{ addon|flag }}
|
||||
<a href="{{ addon.get_absolute_url() }}">
|
||||
<a href="{{ addon.get_url_path() }}">
|
||||
<img alt="" src="{{ addon.thumbnail_url }}">
|
||||
</a>
|
||||
<div class="details">
|
||||
<h4><a href="{{ addon.get_absolute_url() }}">{{ addon.name }}</a></h4>
|
||||
<h4><a href="{{ addon.get_url_path() }}">{{ addon.name }}</a></h4>
|
||||
<p class="meta">
|
||||
{% if sorting == "date" %}
|
||||
{% trans date=addon.last_updated|datetime %}
|
||||
|
@ -90,7 +90,7 @@
|
|||
{% endtrans %}
|
||||
{% else %}
|
||||
{{ addon.average_rating|float|stars }}
|
||||
<a href="{{ addon.get_absolute_url() }}#reviews">
|
||||
<a href="{{ addon.get_url_path() }}#reviews">
|
||||
{# L10n: {0} is the review count. #}
|
||||
{{ ngettext("{0} review", "{0} reviews",
|
||||
addon.total_reviews)|f(addon.total_reviews) }}</a>
|
||||
|
|
|
@ -22,7 +22,7 @@ class File(amo.models.ModelBase):
|
|||
class Meta(amo.models.ModelBase.Meta):
|
||||
db_table = 'files'
|
||||
|
||||
def get_absolute_url(self, src):
|
||||
def get_url_path(self, src):
|
||||
return settings.FILES_URL % (self.id, self.filename, src)
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
{% macro back_to_addon() -%}
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ addon.get_absolute_url() }}">
|
||||
<a href="{{ addon.get_url_path() }}">
|
||||
{{ _('Back to {0}')|f(addon.name) }}
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -35,7 +35,7 @@ def users_list(users):
|
|||
|
||||
def _user_link(user):
|
||||
return u'<a href="%s">%s</a>' % (
|
||||
user.get_absolute_url(), unicode(jinja2.escape(user.display_name)))
|
||||
user.get_url_path(), unicode(jinja2.escape(user.display_name)))
|
||||
|
||||
|
||||
@register.filter
|
||||
|
|
|
@ -65,7 +65,7 @@ class UserProfile(amo.models.ModelBase):
|
|||
def __unicode__(self):
|
||||
return '%s: %s' % (self.id, self.display_name)
|
||||
|
||||
def get_absolute_url(self):
|
||||
def get_url_path(self):
|
||||
return reverse('users.profile', args=[self.id])
|
||||
|
||||
@amo.cached_property
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
{% set addon = review.version.addon %}
|
||||
<div class="hreview">
|
||||
<h4 class="summary">
|
||||
<a class="url" href="{{ addon.get_absolute_url() }}">{{ addon.name }}</a>
|
||||
<a class="url" href="{{ addon.get_url_path() }}">{{ addon.name }}</a>
|
||||
</h4>
|
||||
<p class="description" locale="{{ review.body.locale }}">
|
||||
{{ review.body|nl2br }}
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
<tr>
|
||||
<th>{{ _('Number of Add-ons Developed') }}</th>
|
||||
<td>
|
||||
<a href="{{ profile.get_absolute_url() }}">
|
||||
<a href="{{ profile.get_url_path() }}">
|
||||
{% trans num=profile.addons_listed|length %}
|
||||
{{ num }} Add-on
|
||||
{% pluralize %}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<ul>
|
||||
{% for category in categories %}
|
||||
<li>
|
||||
<a href="{{ category.get_absolute_url() }}">{{ category.name }}</a>
|
||||
<a href="{{ category.get_url_path() }}">{{ category.name }}</a>
|
||||
<span class="items">{{ category.count }}</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
|
Загрузка…
Ссылка в новой задаче