Skip to content

Commit

Permalink
Merge pull request #709 from wagnerand/bug1200790
Browse files Browse the repository at this point in the history
Remove 'Full nomination will be available in...' (bug 1200790)
  • Loading branch information
magopian committed Sep 2, 2015
2 parents 5bc7d20 + da68cd2 commit 5bdfd54
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 96 deletions.
27 changes: 1 addition & 26 deletions apps/addons/models.py
Expand Up @@ -6,7 +6,6 @@
import posixpath
import re
import time
from datetime import datetime, timedelta

from django.conf import settings
from django.core.cache import cache
Expand Down Expand Up @@ -1180,35 +1179,11 @@ def can_request_review(self):
return ()
elif self.status == amo.STATUS_NOMINATED:
return (amo.STATUS_LITE,)
elif self.status == amo.STATUS_UNREVIEWED:
elif self.status in [amo.STATUS_UNREVIEWED, amo.STATUS_LITE]:
return (amo.STATUS_PUBLIC,)
elif self.status == amo.STATUS_LITE:
if self.days_until_full_nomination() == 0:
return (amo.STATUS_PUBLIC,)
else:
# Still in preliminary waiting period...
return ()
else:
return (amo.STATUS_LITE, amo.STATUS_PUBLIC)

def days_until_full_nomination(self):
"""Returns number of days until author can request full review.
If wait period is over or this doesn't apply at all, returns 0 days.
An author must wait 10 days after submitting first LITE approval
to request FULL.
"""
if self.status != amo.STATUS_LITE:
return 0
# Calculate wait time from the earliest submitted version:
qs = (File.objects.filter(version__addon=self, status=self.status)
.order_by('created').values_list('datestatuschanged'))[:1]
if qs:
days_ago = datetime.now() - qs[0][0]
if days_ago < timedelta(days=10):
return 10 - days_ago.days
return 0

def is_persona(self):
return self.type == amo.ADDON_PERSONA

Expand Down
54 changes: 0 additions & 54 deletions apps/addons/tests/test_models.py
Expand Up @@ -1174,60 +1174,6 @@ def test_update_logs(self):
entries = ActivityLog.objects.all()
eq_(entries[0].action, amo.LOG.CHANGE_STATUS.id)

def test_can_request_review_waiting_period(self):
now = datetime.now()
a = Addon.objects.create(type=1)
v = Version.objects.create(addon=a)
# The first LITE version is only 5 days old, no dice.
first_f = File.objects.create(status=amo.STATUS_LITE, version=v)
first_f.update(datestatuschanged=now - timedelta(days=5),
created=now - timedelta(days=20))
# TODO(andym): can this go in Addon.objects.create? bug 618444
a.update(status=amo.STATUS_LITE)
eq_(a.can_request_review(), ())

# Now the first LITE is > 10 days old, change can happen.
first_f.update(datestatuschanged=now - timedelta(days=11))
# Add a second file, to be sure that we test the date
# of the first created file.
second_f = File.objects.create(status=amo.STATUS_LITE, version=v)
second_f.update(datestatuschanged=now - timedelta(days=5))
eq_(a.status, amo.STATUS_LITE)
eq_(a.can_request_review(), (amo.STATUS_PUBLIC,))

def test_days_until_full_nomination(self):
# Normalize to 12am for reliable day subtraction:
now = datetime.now().date()
a = Addon.objects.create(type=1)
v = Version.objects.create(addon=a)
f = File.objects.create(status=amo.STATUS_LITE, version=v)
a.update(status=amo.STATUS_LITE)
f.update(datestatuschanged=now - timedelta(days=4))
eq_(a.days_until_full_nomination(), 6)

f.update(datestatuschanged=now - timedelta(days=1))
eq_(a.days_until_full_nomination(), 9)

f.update(datestatuschanged=now - timedelta(days=10))
eq_(a.days_until_full_nomination(), 0)

f.update(datestatuschanged=now)
eq_(a.days_until_full_nomination(), 10)

# Only calculate days from first submitted version:
f.update(datestatuschanged=now - timedelta(days=2),
created=now - timedelta(days=2))
# Ignore this one:
f2 = File.objects.create(status=amo.STATUS_LITE, version=v)
f2.update(datestatuschanged=now - timedelta(days=1),
created=now - timedelta(days=1))
eq_(a.days_until_full_nomination(), 8)

# Wrong status:
f.update(datestatuschanged=now - timedelta(days=4))
a.update(status=amo.STATUS_PUBLIC)
eq_(a.days_until_full_nomination(), 0)

def setup_files(self, status):
addon = Addon.objects.create(type=1)
version = Version.objects.create(addon=addon)
Expand Down
8 changes: 1 addition & 7 deletions apps/devhub/templates/devhub/versions/list.html
Expand Up @@ -65,9 +65,8 @@
</td>
</tr>
{% set request_reviews=addon.can_request_review() %}
{% set days = addon.days_until_full_nomination() %}
{% set can_cancel=(not addon.is_disabled and addon.is_under_review) %}
{% if full_info and check_addon_ownership(request, addon, dev=True) and (request_reviews or days or can_cancel) %}
{% if full_info and check_addon_ownership(request, addon, dev=True) and (request_reviews or can_cancel) %}
<tr>
<td colspan="0" class="version-status-actions item-actions">
{% set req = {amo.STATUS_PUBLIC: _('Request Full Review'),
Expand All @@ -79,11 +78,6 @@
<button class="link" type="submit">{{ req[status] }}</button> &middot;
</form>
{% endfor %}
{% if days != 0 %}
<span class="warning">{{ ngettext('Full nomination will be available in {0} day',
'Full nomination will be available in {0} days',
days)|f(days) }}</span>
{% endif %}
{% if can_cancel %}
<a href="#" id="cancel-review">{{ _('Cancel Review Request') }}</a>
{% endif %}
Expand Down
9 changes: 0 additions & 9 deletions apps/devhub/tests/test_views_versions.py
@@ -1,5 +1,4 @@
import re
from datetime import datetime, timedelta

import mock
from nose.tools import eq_
Expand Down Expand Up @@ -415,14 +414,6 @@ def test_rejected_request_review(self):
buttons = doc('.version-status-actions form button').text()
eq_(buttons, None)

def test_days_until_full_nomination(self):
f = File.objects.create(status=amo.STATUS_LITE, version=self.version)
f.update(datestatuschanged=datetime.now() - timedelta(days=4))
self.addon.update(status=amo.STATUS_LITE)
doc = pq(self.client.get(self.url).content)
eq_(doc('.version-status-actions .warning').text(),
'Full nomination will be available in 6 days')

def test_add_version_modal(self):
r = self.client.get(self.url)
eq_(r.status_code, 200)
Expand Down

0 comments on commit 5bdfd54

Please sign in to comment.