Verified Commit 03fc4f18 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Add basic membership email

parent cf29cc4f
from datetime import datetime, timedelta
from django.core import mail
from django.template import loader
from django.utils import translation
from django.utils.translation import ugettext as _
from members import models
from thaliawebsite.settings import settings
def send_membership_announcement(dry_run=False):
members = (models.Member.active_members
.filter(user__membership__until__isnull=True))
with mail.get_connection() as connection:
for member in members:
print("Send email to {} ({})".format(member.get_full_name(),
member.user.email))
with translation.override(member.language):
email_body = loader.render_to_string(
'members/email/membership_announcement.txt',
{'name': member.get_full_name()})
mail.EmailMessage(
_('Membership announcement'),
email_body,
settings.WEBSITE_FROM_ADDRESS,
[member.user.email],
bcc=[settings.BOARD_NOTIFICATION_ADDRESS],
connection=connection
).send()
if not dry_run:
mail.mail_managers(
_('Membership announcement sent'),
loader.render_to_string(
'members/email/membership_announcement_notification.txt',
{'members': members}),
connection=connection,
)
Geacht bestuur,
Vanwege de tijd van het jaar heeft de website automatisch iedereen met een studielidmaatschap een email gestuurd.
In die email staat dat het lidmaatschap geldig is zolang ze een studie informatica en/of informatiekunde volgen.
We hebben deze mensen gevraagd om, indien ze afgestudeerd zijn of om een andere reden gestopt met hun studie,
een mailtje te sturen naar info@thalia.nu. Hierbij willen we graag laten weten dat jullie deze emails kunnen verwachten.
De email is gestuurd naar:
{% for member in members %}
* {{ member.full_name }}
{% endfor %}
Kusjes,
De website
{% load i18n %}{% blocktrans %}Dear {{ name }},
You're a study member of Thalia. This means that you'll be a member as long
as you're enrolled in either a computer science or an information science programme.
Are you still studying? Then you don't have to do anything at all!
Did you graduate or stop with your studies for any other reason? Then please
send us an email so that we can update our administration: info@thalia.nu
If you have any questions, then don't hesitate and send us an email.
With kind regards,
The board of Study Association Thalia{% endblocktrans %}g
......@@ -233,6 +233,12 @@ SERVER_EMAIL = DEFAULT_FROM_EMAIL
# Newsletter settings
NEWSLETTER_FROM_ADDRESS = 'nieuwsbrief@thalia.nu'
# Website FROM address
WEBSITE_FROM_ADDRESS = 'no-reply@thalia.nu'
# Board notification address
BOARD_NOTIFICATION_ADDRESS = 'info@thalia.nu'
# Photos settings
PHOTO_UPLOAD_SIZE = 1920, 1080
......
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