Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
Added version list on status page for packaged apps (bug 783669)
Browse files Browse the repository at this point in the history
  • Loading branch information
robhudson committed Aug 22, 2012
1 parent cc314b5 commit 725059e
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 29 deletions.
7 changes: 4 additions & 3 deletions apps/amo/tests/__init__.py
Expand Up @@ -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,
Expand All @@ -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


Expand Down
46 changes: 41 additions & 5 deletions media/css/devreg/status.less
Expand Up @@ -45,24 +45,26 @@
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;
}

.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;
}

Expand All @@ -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;
}
}
}
23 changes: 11 additions & 12 deletions mkt/developers/helpers.py
Expand Up @@ -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


Expand Down
30 changes: 30 additions & 0 deletions mkt/developers/templates/developers/apps/status.html
Expand Up @@ -94,7 +94,37 @@ <h3>
{% 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">
Expand Down
42 changes: 33 additions & 9 deletions mkt/developers/tests/test_views_versions.py
@@ -1,6 +1,5 @@
from nose.tools import eq_
from pyquery import PyQuery as pq
import waffle

import amo
import amo.tests
Expand Down Expand Up @@ -33,7 +32,7 @@ def test_items(self):
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)
Expand All @@ -48,25 +47,20 @@ def test_delete_link(self):
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):
eq_(self.webapp.status, amo.STATUS_PUBLIC)
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):
Expand All @@ -92,3 +86,33 @@ def test_rejected(self):
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'))

0 comments on commit 725059e

Please sign in to comment.