Removed soft deleted apps from queues (bug 778314)

This commit is contained in:
Rob Hudson 2012-07-27 16:56:14 -07:00
Родитель e44915bc5c
Коммит dc402d1c16
4 изменённых файлов: 25 добавлений и 0 удалений

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

@ -395,9 +395,11 @@ class Addon(amo.models.OnChangeMixin, amo.models.ModelBase):
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.save()
models.signals.post_delete.send(sender=Addon, instance=self)
else:
super(Addon, self).delete()
send_mail(subject, email_msg, recipient_list=to)

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

@ -0,0 +1,2 @@
DELETE FROM rereview_queue WHERE addon_id IN (SELECT id FROM addons WHERE addontype_id=11 AND status=11);
DELETE FROM escalation_queue WHERE addon_id IN (SELECT id FROM addons WHERE addontype_id=11 AND status=11);

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

@ -39,3 +39,12 @@ class EscalationQueue(amo.models.ModelBase):
class Meta:
db_table = 'escalation_queue'
def cleanup_queues(sender, instance, **kwargs):
RereviewQueue.objects.filter(addon=instance).delete()
EscalationQueue.objects.filter(addon=instance).delete()
models.signals.post_delete.connect(cleanup_queues, sender=Addon,
dispatch_uid='queue-addon-cleanup')

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

@ -408,6 +408,12 @@ class TestRereviewQueue(AppReviewerTest, AccessMixin):
eq_(doc('.tabnav li a:eq(2)').text(), u'Escalations (1)')
eq_(doc('.tabnav li a:eq(3)').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)
class TestEscalationQueue(AppReviewerTest, AccessMixin):
fixtures = ['base/devicetypes', 'base/users']
@ -511,6 +517,12 @@ class TestEscalationQueue(AppReviewerTest, AccessMixin):
eq_(doc('.tabnav li a:eq(2)').text(), u'Escalations (3)')
eq_(doc('.tabnav li a:eq(3)').text(), u'Moderated Reviews (0)')
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)
class TestReviewApp(AppReviewerTest, AccessMixin):
fixtures = ['base/platforms', 'base/users', 'webapps/337141-steamcube']