Commit c0283d10 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg

Exclude members with auto_renew=True in membership expiration announcements

parent 0a7f54e9
......@@ -127,6 +127,7 @@ def send_expiration_announcement(dry_run=False):
members = (Member.current_members
.filter(membership__until__lte=expiry_date)
.exclude(membership__until__isnull=True)
.exclude(profile__auto_renew=True)
.exclude(email='')
.distinct())
......
......@@ -74,12 +74,29 @@ class EmailsTest(TestCase):
since=timezone.now().replace(year=2017, month=9, day=1),
until=timezone.now().replace(year=2019, month=9, day=1)
)
cls.study_member = Member.objects.create(
cls.year_member_auto_renew = Member.objects.create(
username='test4',
first_name='Test4',
last_name='Example',
email='test4@example.org'
)
Profile.objects.create(
user=cls.year_member_auto_renew,
language='nl',
auto_renew=True
)
Membership.objects.create(
user=cls.year_member_auto_renew,
type=Membership.MEMBER,
since=timezone.now().replace(year=2017, month=9, day=1),
until=timezone.now().replace(year=2019, month=9, day=1)
)
cls.study_member = Member.objects.create(
username='test5',
first_name='Test5',
last_name='Example',
email='test5@example.org'
)
Profile.objects.create(
user=cls.study_member,
language='nl',
......@@ -91,10 +108,10 @@ class EmailsTest(TestCase):
until=None
)
cls.study_member_2 = Member.objects.create(
username='test5',
first_name='Test5',
username='test6',
first_name='Test6',
last_name='Example',
email='test5@example.org'
email='test6@example.org'
)
Profile.objects.create(
user=cls.study_member_2,
......@@ -113,10 +130,10 @@ class EmailsTest(TestCase):
until=None
)
cls.benefactor = Member.objects.create(
username='test6',
first_name='Test6',
username='test7',
first_name='Test7',
last_name='Example',
email='test6@example.org'
email='test7@example.org'
)
Membership.objects.create(
user=cls.benefactor,
......@@ -129,10 +146,10 @@ class EmailsTest(TestCase):
language='nl',
)
cls.honorary_member = Member.objects.create(
username='test7',
first_name='Test7',
username='test8',
first_name='Test8',
last_name='Example',
email='test7@example.org'
email='test8@example.org'
)
Profile.objects.create(
user=cls.honorary_member,
......@@ -151,10 +168,10 @@ class EmailsTest(TestCase):
until=None
)
cls.old_member = Member.objects.create(
username='test8',
first_name='Test8',
username='test9',
first_name='Test9',
last_name='Example',
email='test8@example.org'
email='test9@example.org'
)
Profile.objects.create(
user=cls.old_member,
......@@ -167,10 +184,10 @@ class EmailsTest(TestCase):
until=timezone.now().replace(year=2017, month=6, day=12),
)
cls.future_member = Member.objects.create(
username='test9',
first_name='Test9',
username='test10',
first_name='Test10',
last_name='Example',
email='test9@example.org'
email='test10@example.org'
)
Profile.objects.create(
user=cls.future_member,
......@@ -188,26 +205,27 @@ class EmailsTest(TestCase):
emails.send_membership_announcement()
self.assertEqual(len(mail.outbox), 2)
self.assertEqual(mail.outbox[0].to, ['test4@example.org'])
self.assertEqual(mail.outbox[1].to, ['test5@example.org'])
self.assertEqual(mail.outbox[0].to, ['test5@example.org'])
self.assertEqual(mail.outbox[1].to, ['test6@example.org'])
@freeze_time('2017-10-01')
def test_send_information_request(self):
emails.send_information_request()
self.assertEqual(len(mail.outbox), 8)
self.assertEqual(len(mail.outbox), 9)
self.assertEqual(mail.outbox[0].to, ['test1@example.org'])
self.assertEqual(mail.outbox[0].subject,
'[THALIA] Controle gegevens lidmaatschap')
self.assertEqual(mail.outbox[1].to, ['test2@example.org'])
self.assertEqual(mail.outbox[1].subject,
self.assertEqual(mail.outbox[1].to, ['test10@example.org'])
self.assertEqual(mail.outbox[2].to, ['test2@example.org'])
self.assertEqual(mail.outbox[2].subject,
'[THALIA] Membership information check')
self.assertEqual(mail.outbox[2].to, ['test3@example.org'])
self.assertEqual(mail.outbox[3].to, ['test4@example.org'])
self.assertEqual(mail.outbox[4].to, ['test5@example.org'])
self.assertEqual(mail.outbox[5].to, ['test6@example.org'])
self.assertEqual(mail.outbox[6].to, ['test7@example.org'])
self.assertEqual(mail.outbox[7].to, ['test9@example.org'])
self.assertEqual(mail.outbox[3].to, ['test3@example.org'])
self.assertEqual(mail.outbox[4].to, ['test4@example.org'])
self.assertEqual(mail.outbox[5].to, ['test5@example.org'])
self.assertEqual(mail.outbox[6].to, ['test6@example.org'])
self.assertEqual(mail.outbox[7].to, ['test7@example.org'])
self.assertEqual(mail.outbox[8].to, ['test8@example.org'])
@freeze_time('2018-08-15')
def test_send_expiration_announcement(self):
......@@ -220,7 +238,7 @@ class EmailsTest(TestCase):
self.assertEqual(mail.outbox[1].to, ['test2@example.org'])
self.assertEqual(mail.outbox[1].subject,
'[THALIA] Membership expiration announcement')
self.assertEqual(mail.outbox[2].to, ['test6@example.org'])
self.assertEqual(mail.outbox[2].to, ['test7@example.org'])
@freeze_time('2018-08-15')
def test_send_welcome_message(self):
......
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