Verified Commit 4494b6a2 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Fix automatic member emails

parent 2ff07609
...@@ -8,12 +8,13 @@ from django.utils import translation ...@@ -8,12 +8,13 @@ from django.utils import translation
from django.utils.datetime_safe import datetime from django.utils.datetime_safe import datetime
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from members.models import Member from members.models import Member, Membership
def send_membership_announcement(dry_run=False): def send_membership_announcement(dry_run=False):
members = (Member.current_members members = (Member.current_members
.filter(membership__until__isnull=True) .filter(membership__until__isnull=True)
.exclude(membership__type=Membership.HONORARY)
.distinct()) .distinct())
with mail.get_connection() as connection: with mail.get_connection() as connection:
...@@ -26,7 +27,8 @@ def send_membership_announcement(dry_run=False): ...@@ -26,7 +27,8 @@ def send_membership_announcement(dry_run=False):
'members/email/membership_announcement.txt', 'members/email/membership_announcement.txt',
{'name': member.get_full_name()}) {'name': member.get_full_name()})
mail.EmailMessage( mail.EmailMessage(
_('Membership announcement'), '[THALIA] {}'.format(
_('Membership announcement')),
email_body, email_body,
settings.WEBSITE_FROM_ADDRESS, settings.WEBSITE_FROM_ADDRESS,
[member.email], [member.email],
...@@ -58,7 +60,8 @@ def send_information_request(dry_run=False): ...@@ -58,7 +60,8 @@ def send_information_request(dry_run=False):
{'name': member.get_full_name(), {'name': member.get_full_name(),
'member': member}) 'member': member})
mail.EmailMessage( mail.EmailMessage(
_('Membership information check'), '[THALIA] {}'.format(
_('Membership information check')),
email_body, email_body,
settings.WEBSITE_FROM_ADDRESS, settings.WEBSITE_FROM_ADDRESS,
[member.email], [member.email],
...@@ -80,6 +83,7 @@ def send_expiration_announcement(dry_run=False): ...@@ -80,6 +83,7 @@ def send_expiration_announcement(dry_run=False):
expiry_date = datetime.now() + timedelta(days=31) expiry_date = datetime.now() + timedelta(days=31)
members = (Member.current_members members = (Member.current_members
.filter(membership__until__lte=expiry_date) .filter(membership__until__lte=expiry_date)
.exclude(membership__until__isnull=True)
.distinct()) .distinct())
with mail.get_connection() as connection: with mail.get_connection() as connection:
...@@ -95,10 +99,14 @@ def send_expiration_announcement(dry_run=False): ...@@ -95,10 +99,14 @@ def send_expiration_announcement(dry_run=False):
'membership_price': floatformat( 'membership_price': floatformat(
settings.MEMBERSHIP_PRICES['year'], 2 settings.MEMBERSHIP_PRICES['year'], 2
), ),
'renewal_url': reverse('registrations:renew') 'renewal_url': '{}{}'.format(
'https://thalia.nu',
reverse('registrations:renew')
)
}) })
mail.EmailMessage( mail.EmailMessage(
_('Membership expiration announcement'), '[THALIA] {}'.format(
_('Membership expiration announcement')),
email_body, email_body,
settings.WEBSITE_FROM_ADDRESS, settings.WEBSITE_FROM_ADDRESS,
[member.email], [member.email],
......
Supports Markdown
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