new uploads for a pending version inherit the nomination date (#4959)

This commit is contained in:
Andrew Williamson 2017-03-21 18:33:38 +01:00 коммит произвёл GitHub
Родитель b311c88665
Коммит 71dbbec022
2 изменённых файлов: 24 добавлений и 4 удалений

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

@ -188,6 +188,7 @@ class Version(OnChangeMixin, ModelBase):
File.from_upload(upload, version, platform,
parsed_data=parsed_data, is_beta=is_beta)
version.inherit_nomination(from_statuses=[amo.STATUS_AWAITING_REVIEW])
version.disable_old_files()
# After the upload has been copied to all platforms, remove the upload.
storage.delete(upload.path)
@ -554,6 +555,16 @@ class Version(OnChangeMixin, ModelBase):
# But we need the cache to be flushed.
Version.objects.invalidate(self)
def inherit_nomination(self, from_statuses=None):
last_ver = (Version.objects.filter(addon=self.addon,
channel=amo.RELEASE_CHANNEL_LISTED)
.exclude(nomination=None).exclude(id=self.pk)
.order_by('-nomination'))
if from_statuses:
last_ver = last_ver.filter(files__status__in=from_statuses)
if last_ver.exists():
self.reset_nomination_time(nomination=last_ver[0].nomination)
@property
def unreviewed_files(self):
"""A File is unreviewed if its status is amo.STATUS_AWAITING_REVIEW."""
@ -583,10 +594,7 @@ def inherit_nomination(sender, instance, **kw):
if (instance.nomination is None and
addon.status in amo.UNREVIEWED_ADDON_STATUSES and not
instance.is_beta):
last_ver = (Version.objects.filter(addon=addon)
.exclude(nomination=None).order_by('-nomination'))
if last_ver.exists():
instance.reset_nomination_time(nomination=last_ver[0].nomination)
instance.inherit_nomination()
def update_incompatible_versions(sender, instance, **kw):

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

@ -1449,6 +1449,18 @@ class TestExtensionVersionFromUpload(TestVersionFromUpload):
assert self.addon.feature_compatibility.e10s == (
amo.E10S_COMPATIBLE_WEBEXTENSION)
def test_nomination_inherited_for_updates(self):
assert self.addon.status == amo.STATUS_PUBLIC
self.addon.current_version.update(nomination=self.days_ago(2))
pending_version = version_factory(
addon=self.addon, nomination=self.days_ago(1), version='9.9',
file_kw={'status': amo.STATUS_AWAITING_REVIEW})
assert pending_version.nomination
upload_version = Version.from_upload(
self.upload, self.addon, [self.platform],
amo.RELEASE_CHANNEL_LISTED)
assert upload_version.nomination == pending_version.nomination
class TestSearchVersionFromUpload(TestVersionFromUpload):
filename = 'search.xml'