Added version list on status page for packaged apps (bug 783669)

This commit is contained in:
Rob Hudson 2012-08-22 14:06:24 -07:00
Родитель cc314b5131
Коммит 725059e32d
5 изменённых файлов: 119 добавлений и 29 удалений

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

@ -480,8 +480,8 @@ def addon_factory(version_kw={}, file_kw={}, **kw):
def version_factory(file_kw={}, **kw):
min_app_version = kw.pop('min_app_version', '4.0')
max_app_version = kw.pop('max_app_version', '5.0')
v = Version.objects.create(version='%.1f' % random.uniform(0, 2),
**kw)
version = kw.pop('version', '%.1f' % random.uniform(0, 2))
v = Version.objects.create(version=version, **kw)
if kw.get('addon').type not in (amo.ADDON_PERSONA, amo.ADDON_WEBAPP):
a, _ = Application.objects.get_or_create(id=amo.FIREFOX.id)
av_min, _ = AppVersion.objects.get_or_create(application=a,
@ -497,8 +497,9 @@ def version_factory(file_kw={}, **kw):
def file_factory(**kw):
v = kw['version']
p, _ = Platform.objects.get_or_create(id=amo.PLATFORM_ALL.id)
status = kw.pop('status', amo.STATUS_PUBLIC)
f = File.objects.create(filename='%s-%s' % (v.addon_id, v.id),
platform=p, status=amo.STATUS_PUBLIC, **kw)
platform=p, status=status, **kw)
return f

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

@ -45,9 +45,10 @@
color: @medium-gray;
}
.status-lite-nom i,
.status-lite-nominated i,
.status-nominated b,
.status-unreviewed b {
.status-unreviewed b,
.status-pending b {
font-style: normal;
color: #3e7987;
}
@ -55,14 +56,15 @@
.status-incomplete b,
.status-disabled b,
.status-admin-disabled b,
.status-purgatory b,
.status-waiting b {
.status-purgatory b {
color: #851006;
}
.status-fully-approved b,
.status-public b,
.status-lite b,
.status-lite-nom b {
.status-lite-nom b,
.status-waiting b {
color: #329902;
}
@ -80,3 +82,37 @@
border-color: #ad1212;
text-shadow: 0 -1px #e00;
}
#version-list {
li {
.border-box;
float: left;
padding: 10px 0;
width: 100%;
+ li {
border-top: 1px dotted #eef;
}
&:first-child h4 {
background: #ded;
color: @green;
}
h4 {
background: #f3f3f3;
float: left;
padding: 5px 10px;
}
small {
border-left: 1px solid @faint-gray;
color: @note-gray;
display: block;
float: left;
font-size: 90%;
line-height: 10px;
margin: 4px 0 0 10px;
padding: 7px 0 7px 10px;
}
.buttons {
float: right;
}
}
}

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

@ -147,21 +147,20 @@ def dev_files_status(files, addon):
@register.function
def status_class(addon):
classes = {
amo.STATUS_NULL: 'incomplete',
amo.STATUS_UNREVIEWED: 'unreviewed',
amo.STATUS_NOMINATED: 'nominated',
amo.STATUS_PUBLIC: 'fully-approved',
amo.STATUS_DISABLED: 'admin-disabled',
amo.STATUS_LITE: 'lite',
amo.STATUS_LITE_AND_NOMINATED: 'lite-nom',
amo.STATUS_PURGATORY: 'purgatory',
amo.STATUS_PUBLIC_WAITING: 'waiting',
}
if addon.disabled_by_user and addon.status != amo.STATUS_DISABLED:
cls = 'disabled'
else:
cls = classes.get(addon.status, 'none')
cls = amo.STATUS_CHOICES_API.get(addon.status, 'none')
return 'status-' + cls
@register.function
def file_status_class(addon, version):
if addon.disabled_by_user and addon.status != amo.STATUS_DISABLED:
cls = 'disabled'
else:
file = version.all_files[0]
cls = amo.STATUS_CHOICES_API.get(file.status, 'none')
return 'status-' + cls

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

@ -94,7 +94,37 @@
{% endif %}
</p>
</div>
{% if addon.is_packaged %}
{% set versions = addon.versions.all() %}
{% if versions %}
<h2>{{ _('Packaged Versions') }}</h2>
<div class="island c">
<ul id="version-list">
{% for version in versions %}
<li>
<h4>Version {{ version.version }}</h4>
<small>
{% if addon.disabled_by_user %}
<span class="{{ file_status_class(addon, version) }}"><b>{{ _('Disabled') }}</b></span>
{% else %}
<span class="{{ file_status_class(addon, version) }}"><b>{{ version.status|join(', ') }}</b></span>
{% endif %}
</small>
<small>Submitted <span title="{{ version.created|isotime }}">{{ version.created|datetime }}</span></small>
<div class="buttons">
<a href="{{ version.all_files[0].get_url_path('devhub') }}" class="button download">Download</a>
{# TODO: Install and delete buttons #}
</div>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% endif %}
</section>
<div id="modals">
{% if addon.can_be_deleted() %}
<div id="modal-delete" class="modal modal-delete">

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

@ -1,6 +1,5 @@
from nose.tools import eq_
from pyquery import PyQuery as pq
import waffle
import amo
import amo.tests
@ -33,7 +32,7 @@ class TestAppStatus(amo.tests.TestCase):
eq_(doc('#modal-disable').length, 1)
def test_soft_delete_items(self):
waffle.models.Switch.objects.create(name='soft_delete', active=True)
self.create_switch(name='soft_delete')
doc = pq(self.client.get(self.url).content)
eq_(doc('#version-status').length, 1)
eq_(doc('#version-list').length, 0)
@ -48,17 +47,12 @@ class TestAppStatus(amo.tests.TestCase):
eq_(doc('#delete-addon').length, 1)
eq_(doc('#modal-delete').length, 1)
def test_no_version_list(self):
r = self.client.get(self.url)
doc = pq(r.content)
eq_(doc('#version-list').length, 0)
def test_pending(self):
self.webapp.update(status=amo.STATUS_PENDING)
r = self.client.get(self.url)
eq_(r.status_code, 200)
doc = pq(r.content)
eq_(doc('#version-status .status-none').length, 1)
eq_(doc('#version-status .status-pending').length, 1)
eq_(doc('#rejection').length, 0)
def test_public(self):
@ -66,7 +60,7 @@ class TestAppStatus(amo.tests.TestCase):
r = self.client.get(self.url)
eq_(r.status_code, 200)
doc = pq(r.content)
eq_(doc('#version-status .status-fully-approved').length, 1)
eq_(doc('#version-status .status-public').length, 1)
eq_(doc('#rejection').length, 0)
def test_rejected(self):
@ -92,3 +86,33 @@ class TestAppStatus(amo.tests.TestCase):
eq_(webapp.status, amo.STATUS_PENDING,
'Reapplied apps should get marked as pending')
eq_(unicode(webapp.versions.all()[0].releasenotes), my_reply)
def test_items_packaged(self):
self.webapp.get_latest_file().update(is_packaged=True)
doc = pq(self.client.get(self.url).content)
eq_(doc('#version-status').length, 1)
eq_(doc('#version-list').length, 1)
eq_(doc('#delete-addon').length, 0)
eq_(doc('#modal-delete').length, 0)
eq_(doc('#modal-disable').length, 1)
def test_version_list_packaged(self):
self.webapp.get_latest_file().update(is_packaged=True)
amo.tests.version_factory(addon=self.webapp, version='2.0',
file_kw=dict(is_packaged=True,
status=amo.STATUS_PENDING))
self.webapp = self.get_webapp()
doc = pq(self.client.get(self.url).content)
eq_(doc('#version-status').length, 1)
eq_(doc('#version-list li').length, 2)
# 1 pending and 1 public.
eq_(doc('#version-list span.status-pending').length, 1)
eq_(doc('#version-list span.status-public').length, 1)
# Check version strings and order of versions.
eq_(map(lambda x: x.text, doc('#version-list h4')),
['Version 2.0', 'Version 1.0'])
# Check download url.
eq_(doc('#version-list a.button.download').eq(0).attr('href'),
self.webapp.versions.all()[0].all_files[0].get_url_path('devhub'))
eq_(doc('#version-list a.button.download').eq(1).attr('href'),
self.webapp.versions.all()[1].all_files[0].get_url_path('devhub'))