Order compatible apps (bug 645236)

This commit is contained in:
Gregory Koberger 2012-01-03 16:44:27 -05:00
Родитель 62f01b1c5c
Коммит 9e57295077
3 изменённых файлов: 31 добавлений и 1 удалений

Просмотреть файл

@ -90,7 +90,7 @@
</ul>
<div><strong>{{ _('Compatibility:') }}</strong></div>
<ul>
{% for app, compat in version.compatible_apps.items() %}
{% for app, compat in version.compatible_apps_ordered %}
<li>
<div class="app-icon ed-sprite-{{ app.short }}" title="{{ app.pretty }}"></div>
{{ compat }}

Просмотреть файл

@ -1556,6 +1556,31 @@ class TestReview(ReviewBase):
eq_(tds.eq(1).find('th').text(), "Preliminarily approved")
eq_(tds.eq(1).find('td a').text(), "An editor")
def test_item_history_compat_ordered(self):
""" Make sure that apps in compatibility are ordered. """
self.addon_file(u'something', u'0.2', amo.STATUS_PUBLIC,
amo.STATUS_UNREVIEWED)
a1, c = Application.objects.get_or_create(id=amo.THUNDERBIRD.id)
a2, c = Application.objects.get_or_create(id=amo.SEAMONKEY.id)
av = AppVersion.objects.all()[0]
v = self.addon.versions.all()[0]
ApplicationsVersions.objects.create(version=v,
application=a1, min=av, max=av)
ApplicationsVersions.objects.create(version=v,
application=a2, min=av, max=av)
eq_(self.addon.versions.count(), 1)
url = reverse('editors.review', args=[self.addon.slug])
doc = pq(self.client.get(url).content)
icons = doc('.listing-body .app-icon')
eq_(icons.eq(0).attr('title'), "Firefox")
eq_(icons.eq(1).attr('title'), "SeaMonkey")
eq_(icons.eq(2).attr('title'), "Thunderbird")
def test_item_history_notes(self):
v = self.addon.versions.all()[0]
v.releasenotes = 'hi'

Просмотреть файл

@ -184,6 +184,11 @@ class Version(amo.models.ModelBase):
avs = self.apps.select_related(depth=1)
return self._compat_map(avs)
@amo.cached_property(writable=True)
def compatible_apps_ordered(self):
apps = self.compatible_apps.items()
return sorted(apps, key=lambda v: v[0].short)
def compatible_platforms(self):
"""Returns a dict of compatible file platforms for this version.