EmailMultiAlternatives added: Html version of information check email

parent 1c15ee75
......@@ -3,6 +3,8 @@ from datetime import timedelta
import logging
from django.conf import settings
from django.core.mail import EmailMultiAlternatives
from django.template.loader import get_template
from django.core import mail
from django.template import loader
from django.template.defaultfilters import floatformat
......@@ -94,17 +96,21 @@ def send_information_request(dry_run=False):
'programme': member.profile.get_programme_display()
}.items()
}
email_body = loader.render_to_string(
'members/email/information_check.txt',
email_context)
mail.EmailMessage(
'[THALIA] {}'.format(
_('Membership information check')),
email_body,
settings.DEFAULT_FROM_EMAIL,
[member.email],
connection=connection
).send()
email_context["lang_code"] = member.profile.language
html_template = get_template(
'members/email/information_check.html')
text_template = get_template(
'members/email/information_check.txt')
subject = '[THALIA] ' + _('Membership information check')
html_message = html_template.render(email_context)
text_message = text_template.render(email_context)
msg = EmailMultiAlternatives(subject, text_message,
settings.DEFAULT_FROM_EMAIL,
[member.email]
)
msg.attach_alternative(html_message, "text/html")
msg.send()
if not dry_run:
mail.mail_managers(
......
{% load i18n %}
{% load baseurl %}
{% load static from staticfiles %}
<html style="background-color: #F0F0F0;">
<title>{% trans "membership information check"|capfirst %}</title>
<div style="border-spacing:0px; font-size:15px; font-family:Arial"; width="100%">
<p class="text-center">
<div style="background-color: white; max-width:700px; margin-left:auto; margin-right: auto;">
<div style="background-color:#E6227A; color:white; text-align:center; padding:20px;">
<img src="{% baseurl %}{% static 'img/logo-magenta-bg-'|add:lang_code|add:'.png' %}" style="max-width:200px;">
</div>
<div style="width:calc(100% - 20px); padding:10px; background-color: white; max-width: calc(700px - 20px); margin-left:auto; margin-right: auto;">
{% blocktrans %}
We currently have the following information about you in our database.<br>
Via this email we'd like to ask you to check the accuracy of this data.<br>
{% endblocktrans %}
</div>
<table style="width:100%; background-color: white; max-width: 700px; font-family:Arial; font-size:15px; margin-left:auto; margin-right: auto; padding:10px" >
<tr>
<td>{% trans "username:"|capfirst %}</td>
<td>{{ username }}</td>
</tr>
<tr>
<td>{% trans "name:"|capfirst %}</td>
<td>{{ full_name }}</td>
</tr>
<tr>
<td>{% trans "address:"|capfirst %}</td>
<td>{{ address_street }}<br>{{ address_street2 }}<br>{{ address_postal_code }}<br>{{ address_city }}<br>{{ address_country }}</td>
</tr>
<tr>
<td>{% trans "phone:"|capfirst %}</td>
<td>{{ phone_number }}</td>
</tr>
<tr>
<td>{% trans "date of birth:"|capfirst %}</td>
<td>{{ birthday }}</td>
</tr>
<tr>
<td>{% trans "email address:"|capfirst %}</td>
<td>{{ email }}</td>
</tr>
<tr>
<td>{% trans "student number:"|capfirst %}</td>
<td>{{ student_number }}</td>
</tr>
<tr>
<td>{% trans "cohort:"|capfirst %}</td>
<td>{{ starting_year }}</td>
</tr>
<tr>
<td>{% trans "programme:"|capfirst %}</td>
<td>{{ programme}}</td>
</tr>
</table>
<div style="background-color: white; max-width:700px; margin-left:auto; margin-right: auto; padding:10px">
{% blocktrans %}
<br>
You can changige this data by logging into the website and using the 'edit profile' page.<br>
Unable to edit the incorrect information? Then send an email: info@thalia.nu.<br>
<br>
With kind regards,<br>
<br>
The board of Study Association Thalia<br>
<br>
————<br>
<br>
This email was automatically generated.<br>
{% endblocktrans %}
</div>
</div>
</p>
</div>
......@@ -173,7 +173,7 @@
<tr style="margin-top: 20px;">
<td style="background-color: {{ primary_color }}; overflow: hidden; padding-left:30px; padding-top: 10px; padding-bottom: 10px;">
<a href="{% baseurl %}{% url 'index' %}"><img src="{% baseurl %}{% static 'newsletters/logo-footer-'|add:lang_code|add:'.png' %}" alt="Thalia" width="180" height="75" style="float:left;width: 180px; height: 75px;"></a>
<a href="{% baseurl %}{% url 'index' %}"><img src="{% baseurl %}{% static 'img/logo-magenta-bg-'|add:lang_code|add:'.png' %}" alt="Thalia" width="180" height="75" style="float:left;width: 180px; height: 75px;"></a>
</td>
<td align="center" style="background-color: black; color: white;font-size: 12px; padding: 10px;">
<p style="font-size: 18px; color: white; font-family: 'Calibri', 'Trebuchet MS', sans-serif;">
......
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