Commit 23b21d15 authored by Tom van Bussel's avatar Tom van Bussel
Browse files

Do not send duplicate emails about memberships

It might be the case that members with multiple `Membership` objects are sent
duplicate emails about their expiring memberships.
parent 8f57d9b8
......@@ -12,7 +12,8 @@ from thaliawebsite.settings import settings
def send_membership_announcement(dry_run=False):
members = (models.Member.active_members
.filter(user__membership__until__isnull=True))
.filter(user__membership__until__isnull=True)
.distinct())
with mail.get_connection() as connection:
for member in members:
......@@ -77,7 +78,8 @@ def send_information_request(dry_run=False):
def send_expiration_announcement(dry_run=False):
expiry_date = datetime.now() + timedelta(days=31)
members = (models.Member.active_members
.filter(user__membership__until__lte=expiry_date))
.filter(user__membership__until__lte=expiry_date)
.distinct())
with mail.get_connection() as connection:
for member in members:
......
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