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

Commit

Permalink
Revert "Updated waiting times column on review queues (bug 793914)"
Browse files Browse the repository at this point in the history
This reverts commit 220aaec.
  • Loading branch information
robhudson committed Mar 7, 2013
1 parent baaa786 commit 3ed2398
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 80 deletions.
5 changes: 1 addition & 4 deletions apps/addons/models.py
Expand Up @@ -1560,10 +1560,7 @@ def watch_status(old_attr={}, new_attr={}, instance=None,
if not new_status:
return
addon = instance
if addon.type == amo.ADDON_WEBAPP:
stati = (amo.STATUS_PENDING,)
else:
stati = (amo.STATUS_NOMINATED, amo.STATUS_LITE_AND_NOMINATED)
stati = (amo.STATUS_NOMINATED, amo.STATUS_LITE_AND_NOMINATED)
if new_status in stati and old_attr['status'] != new_status:
try:
latest = addon.versions.latest()
Expand Down
14 changes: 0 additions & 14 deletions apps/addons/tests/test_models.py
Expand Up @@ -1192,13 +1192,6 @@ def test_set_nomination(self):
a.update(status=s)
assert a.versions.latest().nomination

def test_set_nomination_webapp(self):
a = Addon.objects.get(id=3615)
a.update(type=amo.ADDON_WEBAPP, status=amo.STATUS_NULL)
a.versions.latest().update(nomination=None)
a.update(status=amo.STATUS_PENDING)
assert a.versions.latest().nomination

def test_new_version_inherits_nomination(self):
a = Addon.objects.get(id=3615)
ver = 10
Expand All @@ -1209,13 +1202,6 @@ def test_new_version_inherits_nomination(self):
eq_(v.nomination, old_ver.nomination)
ver += 1

def test_new_app_version_inherits_nomination(self):
a = Addon.objects.get(id=3615)
a.update(type=amo.ADDON_WEBAPP, is_packaged=True)
old_ver = a.versions.latest()
v = Version.objects.create(addon=a, version='1.1')
eq_(v.nomination, old_ver.nomination)

def test_beta_version_does_not_inherit_nomination(self):
a = Addon.objects.get(id=3615)
a.update(status=amo.STATUS_LISTED)
Expand Down
43 changes: 8 additions & 35 deletions apps/versions/models.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
import datetime
import os

import django.dispatch
Expand Down Expand Up @@ -107,10 +106,6 @@ def from_upload(cls, upload, addon, platforms, send_signal=True):
if addon.type in [amo.ADDON_SEARCH, amo.ADDON_WEBAPP]:
# Search extensions and webapps are always for all platforms.
platforms = [Platform.objects.get(id=amo.PLATFORM_ALL.id)]
# Always set nomination date when version created if app is public
# or pending.
if addon.status in (amo.STATUS_PUBLIC, amo.STATUS_PENDING):
v.update(nomination=datetime.datetime.now())
else:
platforms = cls._make_safe_platform_files(platforms)

Expand Down Expand Up @@ -458,36 +453,14 @@ def inherit_nomination(sender, instance, **kw):
"""
if kw.get('raw'):
return
if (instance.addon.type == amo.ADDON_WEBAPP and
instance.addon.is_packaged and
not instance.nomination):
if instance.addon.status == amo.STATUS_PENDING:
# App isn't yet public, set newly updated version nominations to
# last versions'.
last_ver = (Version.objects.filter(addon=instance.addon)
.exclude(nomination=None)
.order_by('-nomination'))
if last_ver.exists():
instance.update(nomination=last_ver[0].nomination)
elif instance.addon.status == amo.STATUS_PUBLIC:
# If public, we want to check file status. If the last version's
# file status is not public, we inherit the nomination date.
# Otherwise, we inherit we leave it which resets it.
last_ver = list(Version.objects.filter(addon=instance.addon)
.exclude(id=instance.id)
.order_by('-nomination'))
if last_ver:
if last_ver[0].all_files[0].status != amo.STATUS_PUBLIC:
instance.update(nomination=last_ver[0].nomination)
else:
if (instance.nomination is None
and instance.addon.status in (amo.STATUS_NOMINATED,
amo.STATUS_LITE_AND_NOMINATED)
and not instance.is_beta):
last_ver = (Version.objects.filter(addon=instance.addon)
.exclude(nomination=None).order_by('-nomination'))
if last_ver.exists():
instance.update(nomination=last_ver[0].nomination)
if (instance.nomination is None
and instance.addon.status in (amo.STATUS_NOMINATED,
amo.STATUS_LITE_AND_NOMINATED)
and not instance.is_beta):
last_ver = (Version.objects.filter(addon=instance.addon)
.exclude(nomination=None).order_by('-nomination'))
if last_ver.exists():
instance.update(nomination=last_ver[0].nomination)


def update_incompatible_versions(sender, instance, **kw):
Expand Down
1 change: 1 addition & 0 deletions migrations/546-redacted.sql
@@ -0,0 +1 @@
-- Empty migration because of revert.
5 changes: 0 additions & 5 deletions migrations/546-set-version-nominations-for-apps.sql

This file was deleted.

20 changes: 8 additions & 12 deletions mkt/reviewers/tests/test_views.py
Expand Up @@ -218,11 +218,9 @@ class TestAppQueue(AppReviewerTest, AccessMixin, FlagsMixin, SearchMixin,

def setUp(self):
self.apps = [app_factory(name='XXX',
status=amo.STATUS_PENDING,
version_kw={'nomination': self.days_ago(2)}),
status=amo.STATUS_PENDING),
app_factory(name='YYY',
status=amo.STATUS_PENDING,
version_kw={'nomination': self.days_ago(1)}),
status=amo.STATUS_PENDING),
app_factory(name='ZZZ')]
self.apps[0].update(created=self.days_ago(2))
self.apps[1].update(created=self.days_ago(1))
Expand Down Expand Up @@ -480,12 +478,10 @@ class TestUpdateQueue(AppReviewerTest, AccessMixin, FlagsMixin, SearchMixin,
def setUp(self):
app1 = app_factory(is_packaged=True, name='XXX',
version_kw={'version': '1.0',
'created': self.days_ago(2),
'nomination': self.days_ago(2)})
'created': self.days_ago(2)})
app2 = app_factory(is_packaged=True, name='YYY',
version_kw={'version': '1.0',
'created': self.days_ago(2),
'nomination': self.days_ago(2)})
'created': self.days_ago(2)})

version_factory(addon=app1, version='1.1', created=self.days_ago(1),
nomination=self.days_ago(1),
Expand All @@ -502,8 +498,8 @@ def review_url(self, app):
return reverse('reviewers.apps.review', args=[app.app_slug])

def test_template_links(self):
self.apps[0].versions.latest().update(nomination=self.days_ago(2))
self.apps[1].versions.latest().update(nomination=self.days_ago(1))
self.apps[0].versions.latest().files.update(created=self.days_ago(2))
self.apps[1].versions.latest().files.update(created=self.days_ago(1))
r = self.client.get(self.url)
eq_(r.status_code, 200)
links = pq(r.content)('#addon-queue tbody')('tr td:nth-of-type(2) a')
Expand Down Expand Up @@ -598,8 +594,8 @@ def test_escalated_not_in_queue(self):
def test_order(self):
self.apps[0].update(created=self.days_ago(10))
self.apps[1].update(created=self.days_ago(5))
self.apps[0].versions.latest().update(nomination=self.days_ago(1))
self.apps[1].versions.latest().update(nomination=self.days_ago(4))
self.apps[0].versions.latest().files.update(created=self.days_ago(1))
self.apps[1].versions.latest().files.update(created=self.days_ago(4))
res = self.client.get(self.url)
apps = list(res.context['addons'])
eq_(apps[0].app, self.apps[1])
Expand Down
20 changes: 10 additions & 10 deletions mkt/reviewers/views.py
Expand Up @@ -333,8 +333,9 @@ def _do_sort(request, qs):
"""Column sorting logic based on request GET parameters."""
sort, order = clean_sort_param(request)

if qs.model is not Webapp and sort != 'created':
# For when `Webapp` isn't the base model of the queryset.
if qs.model in [EscalationQueue, RereviewQueue] and sort != 'created':
# For some queues, want to use queue's created field, not the app's
# created field.
sort = 'addon__' + sort

if order == 'asc':
Expand All @@ -354,14 +355,13 @@ def _do_sort(request, qs):
@permission_required('Apps', 'Review')
def queue_apps(request):
excluded_ids = EscalationQueue.uncached.values_list('addon', flat=True)
qs = (Version.uncached.filter(addon__type=amo.ADDON_WEBAPP,
addon__disabled_by_user=False,
addon__status=amo.STATUS_PENDING)
.exclude(addon__id__in=excluded_ids)
.order_by('nomination', 'created'))
qs = (Webapp.uncached.filter(type=amo.ADDON_WEBAPP,
disabled_by_user=False,
status=amo.STATUS_PENDING)
.exclude(id__in=excluded_ids))

apps, search_form = _queue_to_apps(request, qs)
apps = [QueuedApp(v.addon, v.nomination) for v in qs]
qs, search_form = _get_search_form(request, _do_sort(request, qs))
apps = [QueuedApp(app, app.created) for app in qs]

return _queue(request, apps, 'pending', search_form)

Expand Down Expand Up @@ -403,7 +403,7 @@ def queue_updates(request):
.filter(id__in=addon_ids))
qs, search_form = _get_search_form(request, _do_sort(request, qs))

apps = [QueuedApp(app, app.all_versions[0].nomination)
apps = [QueuedApp(app, app.all_versions[0].all_files[0].created)
for app in Webapp.version_and_file_transformer(qs)]
apps = sorted(apps, key=lambda a: a.created)
return _queue(request, apps, 'updates', search_form)
Expand Down

0 comments on commit 3ed2398

Please sign in to comment.