Removed soft_delete waffle switch
This commit is contained in:
Родитель
89e8cfacfa
Коммит
0936f2b868
|
@ -37,7 +37,6 @@ from amo.utils import (attach_trans_dict, cache_ns_key, chunked, find_language,
|
|||
from amo.urlresolvers import get_outgoing_url, reverse
|
||||
from files.models import File
|
||||
from market.models import AddonPremium, Price
|
||||
import mkt.constants
|
||||
from reviews.models import Review
|
||||
import sharing.utils as sharing
|
||||
from stats.models import AddonShareCountTotal
|
||||
|
@ -428,15 +427,15 @@ class Addon(amo.models.OnChangeMixin, amo.models.ModelBase):
|
|||
""" % context
|
||||
log.debug('Sending delete email for %(atype)s %(id)s' % context)
|
||||
subject = 'Deleting %(atype)s %(slug)s (%(id)d)' % context
|
||||
if waffle.switch_is_active('soft_delete'):
|
||||
models.signals.pre_delete.send(sender=Addon, instance=self)
|
||||
self.status = amo.STATUS_DELETED
|
||||
self.slug = self.app_slug = self.app_domain = None
|
||||
self._current_version = None
|
||||
self.save()
|
||||
models.signals.post_delete.send(sender=Addon, instance=self)
|
||||
else:
|
||||
super(Addon, self).delete()
|
||||
|
||||
# Update or NULL out various fields.
|
||||
models.signals.pre_delete.send(sender=Addon, instance=self)
|
||||
self.status = amo.STATUS_DELETED
|
||||
self.slug = self.app_slug = self.app_domain = None
|
||||
self._current_version = None
|
||||
self.save()
|
||||
models.signals.post_delete.send(sender=Addon, instance=self)
|
||||
|
||||
send_mail(subject, email_msg, recipient_list=to)
|
||||
else:
|
||||
super(Addon, self).delete()
|
||||
|
@ -1210,11 +1209,7 @@ class Addon(amo.models.OnChangeMixin, amo.models.ModelBase):
|
|||
return self.is_premium() and self.status in amo.REVIEWED_STATUSES
|
||||
|
||||
def can_be_deleted(self):
|
||||
"""Only incomplete or free addons can be deleted."""
|
||||
if waffle.switch_is_active('soft_delete'):
|
||||
return not self.is_deleted
|
||||
return self.is_incomplete() or not (
|
||||
self.is_premium() or self.is_webapp())
|
||||
return not self.is_deleted
|
||||
|
||||
@classmethod
|
||||
def featured_random(cls, app, lang):
|
||||
|
@ -2281,7 +2276,7 @@ class AddonUpsell(amo.models.ModelBase):
|
|||
|
||||
|
||||
def cleanup_upsell(sender, instance, **kw):
|
||||
if 'raw' in kw or not waffle.switch_is_active('soft_delete'):
|
||||
if 'raw' in kw:
|
||||
return
|
||||
|
||||
both = Q(free=instance) | Q(premium=instance)
|
||||
|
|
|
@ -16,7 +16,6 @@ from django.core.exceptions import ValidationError
|
|||
from django.db import IntegrityError
|
||||
from django.utils import translation
|
||||
|
||||
import waffle
|
||||
from mock import Mock, patch
|
||||
from nose.tools import assert_not_equal, eq_, ok_, raises
|
||||
|
||||
|
@ -371,13 +370,7 @@ class TestAddonModels(amo.tests.TestCase):
|
|||
eq_(len(mail.outbox), 1)
|
||||
assert BlacklistedGuid.objects.filter(guid=a.guid)
|
||||
|
||||
def test_delete_hard(self):
|
||||
deleted_count = Addon.with_deleted.count()
|
||||
self._delete()
|
||||
eq_(deleted_count, Addon.with_deleted.count() + 1)
|
||||
|
||||
def test_delete_soft(self):
|
||||
waffle.models.Switch.objects.create(name='soft_delete', active=True)
|
||||
def test_delete(self):
|
||||
deleted_count = Addon.with_deleted.count()
|
||||
self._delete()
|
||||
eq_(deleted_count, Addon.with_deleted.count())
|
||||
|
@ -394,13 +387,7 @@ class TestAddonModels(amo.tests.TestCase):
|
|||
a.delete('bye')
|
||||
assert absolutify(url) in mail.outbox[0].body
|
||||
|
||||
def test_delete_url_hard(self):
|
||||
count = Addon.with_deleted.count()
|
||||
self._delete_url()
|
||||
eq_(count, Addon.with_deleted.count() + 1)
|
||||
|
||||
def test_delete_url_soft(self):
|
||||
waffle.models.Switch.objects.create(name='soft_delete', active=True)
|
||||
def test_delete_url(self):
|
||||
count = Addon.with_deleted.count()
|
||||
self._delete_url()
|
||||
eq_(count, Addon.with_deleted.count())
|
||||
|
@ -415,27 +402,18 @@ class TestAddonModels(amo.tests.TestCase):
|
|||
eq_(len(mail.outbox), 1)
|
||||
assert reason in mail.outbox[0].body
|
||||
|
||||
def _delete_status_gone_wild(self):
|
||||
def test_delete_status_gone_wild(self):
|
||||
"""
|
||||
Test deleting add-ons where the higheststatus is zero, but there's a
|
||||
non-zero status.
|
||||
"""
|
||||
count = Addon.objects.count()
|
||||
a = Addon.objects.get(pk=3615)
|
||||
a.status = amo.STATUS_UNREVIEWED
|
||||
a.highest_status = 0
|
||||
a.delete('bye')
|
||||
eq_(len(mail.outbox), 1)
|
||||
assert BlacklistedGuid.objects.filter(guid=a.guid)
|
||||
|
||||
def test_delete_status_gone_wild_hard(self):
|
||||
count = Addon.objects.count()
|
||||
self._delete_status_gone_wild()
|
||||
eq_(count, Addon.with_deleted.count() + 1)
|
||||
|
||||
def test_delete_status_gone_wild_soft(self):
|
||||
waffle.models.Switch.objects.create(name='soft_delete', active=True)
|
||||
count = Addon.objects.count()
|
||||
self._delete_status_gone_wild()
|
||||
eq_(count, Addon.with_deleted.count())
|
||||
|
||||
def test_delete_incomplete(self):
|
||||
|
@ -2190,7 +2168,6 @@ class TestAddonUpsell(amo.tests.TestCase):
|
|||
def test_delete(self):
|
||||
self.upsell = AddonUpsell.objects.create(free=self.two,
|
||||
premium=self.one)
|
||||
self.create_switch('soft_delete')
|
||||
# Note: delete ignores if status 0.
|
||||
self.one.update(status=amo.STATUS_PUBLIC)
|
||||
self.one.delete()
|
||||
|
|
|
@ -634,8 +634,6 @@ class TestRereviewQueueTheme(amo.tests.TestCase):
|
|||
|
||||
def test_manager_soft_delete_addons(self):
|
||||
"""Test manager excludes soft delete add-ons."""
|
||||
self.create_switch('soft_delete')
|
||||
|
||||
# Normal RQT object.
|
||||
RereviewQueueTheme.objects.create(
|
||||
theme=addon_factory(type=amo.ADDON_PERSONA).persona, header='',
|
||||
|
@ -648,17 +646,3 @@ class TestRereviewQueueTheme(amo.tests.TestCase):
|
|||
|
||||
eq_(RereviewQueueTheme.objects.count(), 1)
|
||||
eq_(RereviewQueueTheme.with_deleted.count(), 2)
|
||||
|
||||
def test_manager_hard_delete_addons(self):
|
||||
"""Test manager excludes soft delete add-ons."""
|
||||
RereviewQueueTheme.objects.create(
|
||||
theme=addon_factory(type=amo.ADDON_PERSONA).persona, header='',
|
||||
footer='')
|
||||
|
||||
# Deleted add-on RQT object.
|
||||
addon = addon_factory(type=amo.ADDON_PERSONA)
|
||||
RereviewQueueTheme.objects.create(theme=addon.persona, header='', footer='')
|
||||
addon.delete()
|
||||
|
||||
eq_(RereviewQueueTheme.objects.count(), 1)
|
||||
eq_(RereviewQueueTheme.with_deleted.count(), 1)
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
DELETE FROM waffle_switch_amo WHERE name='soft_delete';
|
||||
DELETE FROM waffle_switch_mkt WHERE name='soft_delete';
|
|
@ -445,14 +445,12 @@ class TestAppCreateHandler(CreateHandler, AMOPaths):
|
|||
eq_(res.status_code, 404)
|
||||
|
||||
def test_delete(self):
|
||||
self.create_switch('soft_delete')
|
||||
obj = self.create_app()
|
||||
res = self.client.delete(self.get_url)
|
||||
eq_(res.status_code, 204)
|
||||
assert not Webapp.objects.filter(pk=obj.pk).exists()
|
||||
|
||||
def test_delete_not_mine(self):
|
||||
self.create_switch('soft_delete')
|
||||
obj = self.create_app()
|
||||
obj.authors.clear()
|
||||
res = self.client.delete(self.get_url)
|
||||
|
|
|
@ -587,7 +587,6 @@ class TestStatus(amo.tests.TestCase):
|
|||
self.file = self.webapp.versions.latest().all_files[0]
|
||||
self.file.update(status=amo.STATUS_DISABLED)
|
||||
self.status_url = self.webapp.get_dev_url('versions')
|
||||
self.create_switch('soft_delete')
|
||||
assert self.client.login(username='steamcube@mozilla.com',
|
||||
password='password')
|
||||
|
||||
|
@ -644,14 +643,7 @@ class TestDelete(amo.tests.TestCase):
|
|||
def get_webapp(self):
|
||||
return Addon.objects.no_cache().get(id=337141)
|
||||
|
||||
def test_post_not(self):
|
||||
# Update this test when BrowserID re-auth is available.
|
||||
r = self.client.post(self.url, follow=True)
|
||||
eq_(pq(r.content)('.notification-box').text(),
|
||||
'Paid apps cannot be deleted. Disable this app instead.')
|
||||
|
||||
def test_post(self):
|
||||
waffle.models.Switch.objects.create(name='soft_delete', active=True)
|
||||
r = self.client.post(self.url, follow=True)
|
||||
eq_(pq(r.content)('.notification-box').text(), 'App deleted.')
|
||||
self.assertRaises(Addon.DoesNotExist, self.get_webapp)
|
||||
|
@ -908,7 +900,6 @@ class TestDeleteApp(amo.tests.TestCase):
|
|||
self.versions_url = self.webapp.get_dev_url('versions')
|
||||
self.dev_url = reverse('mkt.developers.apps')
|
||||
self.client.login(username='admin@mozilla.com', password='password')
|
||||
waffle.models.Switch.objects.create(name='soft_delete', active=True)
|
||||
|
||||
def test_delete_get(self):
|
||||
eq_(self.client.get(self.url).status_code, 405)
|
||||
|
|
|
@ -41,16 +41,6 @@ class TestVersion(amo.tests.TestCase):
|
|||
self.url)
|
||||
|
||||
def test_items(self):
|
||||
doc = pq(self.client.get(self.url).content)
|
||||
eq_(doc('#version-status').length, 1)
|
||||
eq_(doc('#version-list').length, 0)
|
||||
eq_(doc('#delete-addon').length, 0)
|
||||
eq_(doc('#modal-delete').length, 0)
|
||||
eq_(doc('#modal-disable').length, 1)
|
||||
eq_(doc('#modal-delete-version').length, 0)
|
||||
|
||||
def test_soft_delete_items(self):
|
||||
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)
|
||||
|
@ -274,7 +264,6 @@ class TestVersionPackaged(amo.tests.WebappTestCase):
|
|||
self.delete_url = self.app.get_dev_url('versions.delete')
|
||||
|
||||
def test_items_packaged(self):
|
||||
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, 1)
|
||||
|
|
|
@ -637,7 +637,6 @@ class TestAppSearch(ESTestCase, SearchTestMixin):
|
|||
self.test_by_name_part()
|
||||
|
||||
def test_by_deleted_app(self):
|
||||
self.create_switch('soft_delete')
|
||||
self.app.delete()
|
||||
self.refresh('webapp')
|
||||
data = self.search(q='something')
|
||||
|
@ -701,7 +700,6 @@ class TestAppSummary(AppSummaryTest):
|
|||
self._setUp()
|
||||
|
||||
def test_app_deleted(self):
|
||||
self.create_switch('soft_delete')
|
||||
self.app.delete()
|
||||
self.summary()
|
||||
|
||||
|
|
|
@ -649,7 +649,6 @@ class TestRereviewQueue(AppReviewerTest, AccessMixin, FlagsMixin, SearchMixin,
|
|||
eq_(doc('.tabnav li a:eq(4)').text(), u'Moderated Reviews (0)')
|
||||
|
||||
def test_addon_deleted(self):
|
||||
self.create_switch(name='soft_delete')
|
||||
app = self.apps[0]
|
||||
app.delete()
|
||||
eq_(RereviewQueue.objects.filter(addon=app).exists(), False)
|
||||
|
@ -1030,7 +1029,6 @@ class TestEscalationQueue(AppReviewerTest, AccessMixin, FlagsMixin,
|
|||
eq_(tds.eq(0).text(), '1')
|
||||
|
||||
def test_addon_deleted(self):
|
||||
self.create_switch(name='soft_delete')
|
||||
app = self.apps[0]
|
||||
app.delete()
|
||||
eq_(EscalationQueue.objects.filter(addon=app).exists(), False)
|
||||
|
|
|
@ -494,8 +494,6 @@ class TestThemeQueueRereview(ThemeReviewTestMixin, amo.tests.TestCase):
|
|||
Test soft-deleted add-ons don't cause trouble like they did to me
|
||||
for the last 6 months! #liberation
|
||||
"""
|
||||
self.create_switch('soft_delete')
|
||||
|
||||
# Normal RQT object.
|
||||
RereviewQueueTheme.objects.create(
|
||||
theme=addon_factory(type=amo.ADDON_PERSONA).persona, header='',
|
||||
|
@ -514,29 +512,6 @@ class TestThemeQueueRereview(ThemeReviewTestMixin, amo.tests.TestCase):
|
|||
eq_(doc('.theme').length, 1)
|
||||
eq_(RereviewQueueTheme.with_deleted.count(), 2)
|
||||
|
||||
def test_hard_deleted_addon(self):
|
||||
"""
|
||||
Test soft-deleted add-ons don't cause trouble like they did to me
|
||||
for the last 6 months! #liberation
|
||||
"""
|
||||
# Normal RQT object.
|
||||
RereviewQueueTheme.objects.create(
|
||||
theme=addon_factory(type=amo.ADDON_PERSONA).persona, header='',
|
||||
footer='')
|
||||
|
||||
# Deleted add-on RQT object.
|
||||
addon = addon_factory(type=amo.ADDON_PERSONA)
|
||||
RereviewQueueTheme.objects.create(theme=addon.persona, header='',
|
||||
footer='')
|
||||
addon.delete()
|
||||
|
||||
self.login('senior_persona_reviewer@mozilla.com')
|
||||
r = self.client.get(self.queue_url)
|
||||
eq_(r.status_code, 200)
|
||||
doc = pq(r.content)
|
||||
eq_(doc('.theme').length, 1)
|
||||
eq_(RereviewQueueTheme.with_deleted.count(), 1)
|
||||
|
||||
@mock.patch.object(settings, 'LOCAL_MIRROR_URL', '')
|
||||
@mock.patch('mkt.reviewers.tasks.send_mail_jinja')
|
||||
@mock.patch('mkt.reviewers.tasks.create_persona_preview_images')
|
||||
|
|
|
@ -36,7 +36,6 @@ class TestApi(BaseOAuth, ESTestCase):
|
|||
fixtures = fixture('webapp_337141')
|
||||
|
||||
def setUp(self):
|
||||
self.create_switch('soft_delete')
|
||||
self.client = OAuthClient(None)
|
||||
self.url = list_url('search')
|
||||
self.webapp = Webapp.objects.get(pk=337141)
|
||||
|
|
|
@ -140,7 +140,6 @@ class TestVersionViewSet(RestOAuth):
|
|||
res = self.client.get(url)
|
||||
eq_(res.status_code, 200)
|
||||
|
||||
self.create_switch('soft_delete')
|
||||
self.app.delete()
|
||||
|
||||
res = self.client.get(url)
|
||||
|
|
|
@ -15,7 +15,6 @@ from django.db.models.signals import post_delete, post_save
|
|||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import mock
|
||||
import waffle
|
||||
from nose.tools import eq_, ok_, raises
|
||||
|
||||
import amo
|
||||
|
@ -49,16 +48,6 @@ from mkt.webapps.models import (AddonExcludedRegion, AppFeatures, AppManifest,
|
|||
class TestWebapp(amo.tests.TestCase):
|
||||
fixtures = fixture('prices')
|
||||
|
||||
def test_hard_deleted(self):
|
||||
w = Webapp.objects.create(status=amo.STATUS_PUBLIC)
|
||||
# Until bug 755214 is fixed, `len` that ish.
|
||||
eq_(len(Webapp.objects.all()), 1)
|
||||
eq_(len(Webapp.with_deleted.all()), 1)
|
||||
|
||||
w.delete('boom shakalakalaka')
|
||||
eq_(len(Webapp.objects.all()), 0)
|
||||
eq_(len(Webapp.with_deleted.all()), 0)
|
||||
|
||||
def test_delete_reason(self):
|
||||
"""Test deleting with a reason gives the reason in the mail."""
|
||||
reason = u'trêason'
|
||||
|
@ -70,8 +59,6 @@ class TestWebapp(amo.tests.TestCase):
|
|||
assert reason in mail.outbox[0].body
|
||||
|
||||
def test_soft_deleted(self):
|
||||
waffle.models.Switch.objects.create(name='soft_delete', active=True)
|
||||
|
||||
w = Webapp.objects.create(slug='ballin', app_slug='app-ballin',
|
||||
app_domain='http://omg.org/yes',
|
||||
status=amo.STATUS_PENDING)
|
||||
|
@ -89,8 +76,6 @@ class TestWebapp(amo.tests.TestCase):
|
|||
eq_(getattr(post_mortem[0], attr), None)
|
||||
|
||||
def test_with_deleted_count(self):
|
||||
waffle.models.Switch.objects.create(name='soft_delete', active=True)
|
||||
|
||||
w = Webapp.objects.create(slug='ballin', app_slug='app-ballin',
|
||||
app_domain='http://omg.org/yes',
|
||||
status=amo.STATUS_PENDING)
|
||||
|
@ -489,7 +474,6 @@ class TestWebapp(amo.tests.TestCase):
|
|||
class DeletedAppTests(amo.tests.ESTestCase):
|
||||
|
||||
def test_soft_deleted_no_current_version(self):
|
||||
waffle.models.Switch.objects.create(name='soft_delete', active=True)
|
||||
webapp = amo.tests.app_factory()
|
||||
webapp._current_version = None
|
||||
webapp.save()
|
||||
|
@ -497,7 +481,6 @@ class DeletedAppTests(amo.tests.ESTestCase):
|
|||
eq_(webapp.current_version, None)
|
||||
|
||||
def test_soft_deleted_no_latest_version(self):
|
||||
waffle.models.Switch.objects.create(name='soft_delete', active=True)
|
||||
webapp = amo.tests.app_factory()
|
||||
webapp._latest_version = None
|
||||
webapp.save()
|
||||
|
|
Загрузка…
Ссылка в новой задаче