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

Commit 93c29e7

Browse files
author
Rob Hudson
committed
Update status while disabled (bug 1042968)
1 parent ae9ad63 commit 93c29e7

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

mkt/developers/tests/test_views_versions.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,17 @@ def test_delete_version(self):
387387
eq_(str(version[0].status[0]),
388388
str(amo.MKT_STATUS_CHOICES[amo.STATUS_DELETED]))
389389

390+
def test_delete_version_while_disabled(self):
391+
self.app.update(disabled_by_user=True)
392+
version = self.app.latest_version
393+
394+
res = self.client.post(self.delete_url, {'version_id': version.pk})
395+
eq_(res.status_code, 302)
396+
397+
eq_(self.get_app().status, amo.STATUS_NULL)
398+
version = Version.with_deleted.get(pk=version.pk)
399+
assert version.deleted
400+
390401
def test_anonymous_delete_redirects(self):
391402
self.client.logout()
392403
version = self.app.versions.latest()

mkt/webapps/models.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -612,29 +612,6 @@ def get_icon_url(self, size):
612612
return static_url('ADDON_ICON_URL') % (
613613
split_id.group(2) or 0, self.id, size, suffix)
614614

615-
@write
616-
def update_status(self):
617-
if (self.status in [amo.STATUS_NULL, amo.STATUS_DELETED] or
618-
self.is_disabled):
619-
return
620-
621-
def logit(reason, old=self.status):
622-
log.info('Changing addon status [%s]: %s => %s (%s).'
623-
% (self.id, old, self.status, reason))
624-
amo.log(amo.LOG.CHANGE_STATUS, self.get_status_display(), self)
625-
626-
versions = self.versions.all()
627-
if not versions.exists():
628-
self.update(status=amo.STATUS_NULL)
629-
logit('no versions')
630-
elif not (versions.filter(files__isnull=False).exists()):
631-
self.update(status=amo.STATUS_NULL)
632-
logit('no versions with files')
633-
elif (self.status == amo.STATUS_PUBLIC and
634-
not versions.filter(files__status=amo.STATUS_PUBLIC).exists()):
635-
self.update(status=amo.STATUS_PENDING)
636-
logit('no reviewed files')
637-
638615
@staticmethod
639616
def attach_related_versions(addons, addon_dict=None):
640617
if addon_dict is None:
@@ -1784,8 +1761,7 @@ def mark_done(self):
17841761
self.update(status=amo.WEBAPPS_UNREVIEWED_STATUS)
17851762

17861763
def update_status(self, **kwargs):
1787-
if (self.is_deleted or self.is_disabled or
1788-
self.status == amo.STATUS_BLOCKED):
1764+
if self.is_deleted or self.status == amo.STATUS_BLOCKED:
17891765
return
17901766

17911767
def _log(reason, old=self.status):

0 commit comments

Comments
 (0)