Commit 042adce1 authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

Add option for sending test results to mailing list only

... and clarify descriptions of the other options.
Signed-off-by: Arkadiusz Hiler's avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent 8738d513
Pipeline #18916 passed with stage
in 1 minute and 21 seconds
# -*- coding: utf-8 -*-
# Generated by Django 1.11.18 on 2019-02-13 22:00
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('patchwork', '0030_auto_20181221_2209'),
]
operations = [
migrations.AlterField(
model_name='test',
name='mail_recipient',
field=models.SmallIntegerField(choices=[(0, 'none'), (1, 'submitter'), (2, 'submitter and mailing list'), (3, 'recipient list'), (4, 'mailing list only')], default=0),
),
]
......@@ -747,11 +747,14 @@ class Test(models.Model):
RECIPIENT_MAILING_LIST = 2
# send mail to the addresses listed in the mail_to_list field only
RECIPIENT_TO_LIST = 3
# send mail to mailing list only
RECIPIENT_MAILING_LIST_ONLY = 4
RECIPIENT_CHOICES = (
(RECIPIENT_NONE, 'none'),
(RECIPIENT_SUBMITTER, 'submitter'),
(RECIPIENT_MAILING_LIST, 'mailing list'),
(RECIPIENT_MAILING_LIST, 'submitter and mailing list'),
(RECIPIENT_TO_LIST, 'recipient list'),
(RECIPIENT_MAILING_LIST_ONLY, 'mailing list only'),
)
# send result mail on any state (but pending)
......
......@@ -878,6 +878,17 @@ class TestResultTest(APITestBase):
mail.outbox = []
self._configure_test(url, 'super test',
Test.RECIPIENT_MAILING_LIST_ONLY,
Test.CONDITION_ALWAYS)
self._post_result(url, 'super test', 'success')
self.assertEqual(len(mail.outbox), 1)
email = mail.outbox[0]
self.assertEqual(email.cc, [])
self.assertEqual(email.to, [self.project.listemail])
mail.outbox = []
self._configure_test(url, 'super test',
Test.RECIPIENT_TO_LIST, Test.CONDITION_ALWAYS,
to_list=to_list, cc_list=cc_list)
......
......@@ -408,6 +408,8 @@ class ResultMixin(object):
elif instance.test.mail_recipient == Test.RECIPIENT_MAILING_LIST:
to.append(check_obj.submitter.email_name())
cc.append(check_obj.project.listemail)
elif instance.test.mail_recipient == Test.RECIPIENT_MAILING_LIST_ONLY:
to.append(check_obj.project.listemail)
if instance.test.mail_recipient != Test.RECIPIENT_NONE and \
(instance.test.mail_to_list or instance.test.mail_cc_list):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment