Commit 33b374ff authored by Thom Wiggers's avatar Thom Wiggers 📐

Merge branch 'fix/members-emails-check-validity' into 'master'

Check validity of email addresses in members emails

Closes #677

See merge request !913
parents d009911c 41976580
......@@ -57,8 +57,8 @@ payments.views module
:undoc-members:
:show-inheritance:
payments\.widgets module
------------------------
payments.widgets module
-----------------------
.. automodule:: payments.widgets
:members:
......
......@@ -21,6 +21,7 @@ def send_membership_announcement(dry_run=False):
members = (Member.current_members
.filter(membership__until__isnull=True)
.exclude(membership__type=Membership.HONORARY)
.exclude(email='')
.distinct())
with mail.get_connection() as connection:
......@@ -58,7 +59,7 @@ def send_information_request(dry_run=False):
:param dry_run: does not really send emails if True
"""
members = Member.current_members.all()
members = Member.current_members.all().exclude(email='')
with mail.get_connection() as connection:
for member in members:
......@@ -101,6 +102,7 @@ def send_expiration_announcement(dry_run=False):
members = (Member.current_members
.filter(membership__until__lte=expiry_date)
.exclude(membership__until__isnull=True)
.exclude(email='')
.distinct())
with mail.get_connection() as connection:
......
......@@ -11,6 +11,21 @@ class EmailsTest(TestCase):
@classmethod
def setUpTestData(cls):
cls.member_no_mail = Member.objects.create(
username='no_mail_test',
first_name='Nomail',
last_name='Example'
)
Profile.objects.create(
user=cls.member_no_mail,
language='en',
)
Membership.objects.create(
user=cls.member_no_mail,
type=Membership.MEMBER,
since=timezone.now().replace(year=2017, month=9, day=1),
until=timezone.now().replace(year=2018, month=9, day=1)
)
cls.year_member_nl = Member.objects.create(
username='test1',
first_name='Test1',
......
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