Verified Commit 2c52ac40 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Add documentation to membership emails

parent 4494b6a2
...@@ -12,6 +12,12 @@ from members.models import Member, Membership ...@@ -12,6 +12,12 @@ from members.models import Member, Membership
def send_membership_announcement(dry_run=False): def send_membership_announcement(dry_run=False):
"""
Sends an email to all members with a never ending membership
excluding honorary members
:param dry_run: does not really send emails if True
"""
members = (Member.current_members members = (Member.current_members
.filter(membership__until__isnull=True) .filter(membership__until__isnull=True)
.exclude(membership__type=Membership.HONORARY) .exclude(membership__type=Membership.HONORARY)
...@@ -47,6 +53,11 @@ def send_membership_announcement(dry_run=False): ...@@ -47,6 +53,11 @@ def send_membership_announcement(dry_run=False):
def send_information_request(dry_run=False): def send_information_request(dry_run=False):
"""
Sends an email to all members to have them check their personal information
:param dry_run: does not really send emails if True
"""
members = Member.current_members.all() members = Member.current_members.all()
with mail.get_connection() as connection: with mail.get_connection() as connection:
...@@ -80,6 +91,12 @@ def send_information_request(dry_run=False): ...@@ -80,6 +91,12 @@ def send_information_request(dry_run=False):
def send_expiration_announcement(dry_run=False): def send_expiration_announcement(dry_run=False):
"""
Sends an email to all members whose membership will end in the next 31 days
to warn them about this
:param dry_run: does not really send emails if True
"""
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)
...@@ -125,6 +142,13 @@ def send_expiration_announcement(dry_run=False): ...@@ -125,6 +142,13 @@ def send_expiration_announcement(dry_run=False):
def send_welcome_message(user, password, language): def send_welcome_message(user, password, language):
"""
Sends an email to a new mail welcoming them
:param user: the new user
:param password: randomly generated password
:param language: selected language during registration
"""
with translation.override(language): with translation.override(language):
email_body = loader.render_to_string( email_body = loader.render_to_string(
'members/email/welcome.txt', 'members/email/welcome.txt',
...@@ -139,6 +163,12 @@ def send_welcome_message(user, password, language): ...@@ -139,6 +163,12 @@ def send_welcome_message(user, password, language):
def send_email_change_confirmation_messages(change_request): def send_email_change_confirmation_messages(change_request):
"""
Sends emails to the old and new email address of a member to
confirm the email change
:param change_request the email change request entered by the user
"""
member = change_request.member member = change_request.member
with translation.override(member.profile.language): with translation.override(member.profile.language):
mail.EmailMessage( mail.EmailMessage(
...@@ -179,6 +209,11 @@ def send_email_change_confirmation_messages(change_request): ...@@ -179,6 +209,11 @@ def send_email_change_confirmation_messages(change_request):
def send_email_change_completion_message(change_request): def send_email_change_completion_message(change_request):
"""
Sends email to the member to confirm the email change
:param change_request the email change request entered by the user
"""
change_request.member.email_user( change_request.member.email_user(
'[THALIA] {}'.format(_('Your email address has been changed')), '[THALIA] {}'.format(_('Your email address has been changed')),
loader.render_to_string( loader.render_to_string(
......
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