email app developers of pending apps too (bug 800190)
This commit is contained in:
Родитель
dad7ff9e45
Коммит
410e49737c
|
@ -35,9 +35,9 @@ class DevMailerForm(happyforms.Form):
|
||||||
('sdk', 'Developers of active SDK add-ons'),
|
('sdk', 'Developers of active SDK add-ons'),
|
||||||
('apps', 'Developers of active apps (not add-ons)'),
|
('apps', 'Developers of active apps (not add-ons)'),
|
||||||
('payments',
|
('payments',
|
||||||
'Developers of active apps (not add-ons) with payments'),
|
'Developers of non-deleted apps (not add-ons) with payments'),
|
||||||
('desktop_apps',
|
('desktop_apps',
|
||||||
'Developers of active apps supported on desktop')]
|
'Developers of non-deleted apps supported on desktop')]
|
||||||
recipients = forms.ChoiceField(choices=_choices, required=True)
|
recipients = forms.ChoiceField(choices=_choices, required=True)
|
||||||
subject = forms.CharField(widget=forms.TextInput(attrs=dict(size='100')),
|
subject = forms.CharField(widget=forms.TextInput(attrs=dict(size='100')),
|
||||||
required=True)
|
required=True)
|
||||||
|
|
|
@ -33,6 +33,7 @@ from users.models import UserProfile
|
||||||
from users.utils import get_task_user
|
from users.utils import get_task_user
|
||||||
from versions.models import ApplicationsVersions, Version
|
from versions.models import ApplicationsVersions, Version
|
||||||
from zadmin import forms, tasks
|
from zadmin import forms, tasks
|
||||||
|
from zadmin.forms import DevMailerForm
|
||||||
from zadmin.models import EmailPreviewTopic, ValidationJob, ValidationResult
|
from zadmin.models import EmailPreviewTopic, ValidationJob, ValidationResult
|
||||||
from zadmin.views import completed_versions_dirty, find_files
|
from zadmin.views import completed_versions_dirty, find_files
|
||||||
|
|
||||||
|
@ -1930,6 +1931,18 @@ class TestEmailDevs(amo.tests.TestCase):
|
||||||
self.assertNoFormErrors(res)
|
self.assertNoFormErrors(res)
|
||||||
eq_(len(mail.outbox), 1)
|
eq_(len(mail.outbox), 1)
|
||||||
|
|
||||||
|
mail.outbox = []
|
||||||
|
self.addon.update(status=amo.STATUS_PENDING)
|
||||||
|
res = self.post(recipients='payments')
|
||||||
|
self.assertNoFormErrors(res)
|
||||||
|
eq_(len(mail.outbox), 1)
|
||||||
|
|
||||||
|
mail.outbox = []
|
||||||
|
self.addon.update(status=amo.STATUS_DELETED)
|
||||||
|
res = self.post(recipients='payments')
|
||||||
|
self.assertNoFormErrors(res)
|
||||||
|
eq_(len(mail.outbox), 0)
|
||||||
|
|
||||||
def test_only_desktop_apps(self):
|
def test_only_desktop_apps(self):
|
||||||
from addons.models import AddonDeviceType
|
from addons.models import AddonDeviceType
|
||||||
self.addon.update(type=amo.ADDON_WEBAPP)
|
self.addon.update(type=amo.ADDON_WEBAPP)
|
||||||
|
@ -1939,23 +1952,46 @@ class TestEmailDevs(amo.tests.TestCase):
|
||||||
self.assertNoFormErrors(res)
|
self.assertNoFormErrors(res)
|
||||||
eq_(len(mail.outbox), 0)
|
eq_(len(mail.outbox), 0)
|
||||||
|
|
||||||
|
mail.outbox = []
|
||||||
AddonDeviceType.objects.create(addon=self.addon,
|
AddonDeviceType.objects.create(addon=self.addon,
|
||||||
device_type=amo.DEVICE_DESKTOP.id)
|
device_type=amo.DEVICE_DESKTOP.id)
|
||||||
res = self.post(recipients='desktop_apps')
|
res = self.post(recipients='desktop_apps')
|
||||||
self.assertNoFormErrors(res)
|
self.assertNoFormErrors(res)
|
||||||
eq_(len(mail.outbox), 1)
|
eq_(len(mail.outbox), 1)
|
||||||
|
|
||||||
|
mail.outbox = []
|
||||||
|
self.addon.update(status=amo.STATUS_PENDING)
|
||||||
|
res = self.post(recipients='desktop_apps')
|
||||||
|
self.assertNoFormErrors(res)
|
||||||
|
eq_(len(mail.outbox), 1)
|
||||||
|
|
||||||
|
mail.outbox = []
|
||||||
|
self.addon.update(status=amo.STATUS_DELETED)
|
||||||
|
res = self.post(recipients='desktop_apps')
|
||||||
|
self.assertNoFormErrors(res)
|
||||||
|
eq_(len(mail.outbox), 0)
|
||||||
|
|
||||||
def test_only_apps(self):
|
def test_only_apps(self):
|
||||||
self.addon.update(type=amo.ADDON_WEBAPP)
|
self.addon.update(type=amo.ADDON_WEBAPP)
|
||||||
res = self.post(recipients='apps')
|
res = self.post(recipients='apps')
|
||||||
self.assertNoFormErrors(res)
|
self.assertNoFormErrors(res)
|
||||||
eq_(len(mail.outbox), 1)
|
eq_(len(mail.outbox), 1)
|
||||||
|
|
||||||
def test_ignore_deleted(self):
|
def test_ignore_deleted_always(self):
|
||||||
self.addon.update(status=amo.STATUS_DELETED)
|
self.addon.update(status=amo.STATUS_DELETED)
|
||||||
res = self.post()
|
for name, label in DevMailerForm._choices:
|
||||||
self.assertNoFormErrors(res)
|
res = self.post(recipients=name)
|
||||||
eq_(len(mail.outbox), 0)
|
self.assertNoFormErrors(res)
|
||||||
|
eq_(len(mail.outbox), 0)
|
||||||
|
|
||||||
|
def test_exclude_pending_for_addons(self):
|
||||||
|
self.addon.update(status=amo.STATUS_PENDING)
|
||||||
|
for name, label in DevMailerForm._choices:
|
||||||
|
if name in ('payments', 'desktop_apps'):
|
||||||
|
continue
|
||||||
|
res = self.post(recipients=name)
|
||||||
|
self.assertNoFormErrors(res)
|
||||||
|
eq_(len(mail.outbox), 0)
|
||||||
|
|
||||||
|
|
||||||
class TestPerms(amo.tests.TestCase):
|
class TestPerms(amo.tests.TestCase):
|
||||||
|
|
|
@ -620,11 +620,15 @@ def email_devs(request):
|
||||||
preview_csv = None
|
preview_csv = None
|
||||||
if request.method == 'POST' and form.is_valid():
|
if request.method == 'POST' and form.is_valid():
|
||||||
data = form.cleaned_data
|
data = form.cleaned_data
|
||||||
listed = amo.LISTED_STATUSES
|
|
||||||
qs = (AddonUser.objects.filter(role__in=(amo.AUTHOR_ROLE_DEV,
|
qs = (AddonUser.objects.filter(role__in=(amo.AUTHOR_ROLE_DEV,
|
||||||
amo.AUTHOR_ROLE_OWNER),
|
amo.AUTHOR_ROLE_OWNER))
|
||||||
addon__status__in=listed)
|
|
||||||
.exclude(user__email=None))
|
.exclude(user__email=None))
|
||||||
|
|
||||||
|
if data['recipients'] in ('payments', 'desktop_apps'):
|
||||||
|
qs = qs.exclude(addon__status=amo.STATUS_DELETED)
|
||||||
|
else:
|
||||||
|
qs = qs.filter(addon__status__in=amo.LISTED_STATUSES)
|
||||||
|
|
||||||
if data['recipients'] == 'eula':
|
if data['recipients'] == 'eula':
|
||||||
qs = qs.exclude(addon__eula=None)
|
qs = qs.exclude(addon__eula=None)
|
||||||
elif data['recipients'] == 'payments':
|
elif data['recipients'] == 'payments':
|
||||||
|
|
Загрузка…
Ссылка в новой задаче