Commit 64dc0ac4 authored by Louis Dod's avatar Louis Dod
Browse files

Adds mail-notifiaction for organization-mail

(temporary - will get replaced by interface-settings later)
parent c907d2ce
......@@ -7,6 +7,8 @@ KEY = '...'
# Mail:
ORGANIZATION_ADDRESS = 'registrations@example-domain.com'
EMAIL_HOST = 'mail.example-domain.com'
EMAIL_PORT = 465 # SMTP-Port (could also be 587)
EMAIL_HOST_USER = ''
......
......@@ -153,6 +153,8 @@ REGISTRATION_OPENING_TIME = datetime.time(15, 00)
# Mail-Settings:
ORGANIZATION_ADDRESS = projectSecrets.ORGANIZATION_ADDRESS
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = projectSecrets.EMAIL_HOST
EMAIL_PORT = projectSecrets. EMAIL_PORT
......
......@@ -27,3 +27,28 @@ def send_registration_confirmation_mail(candidate, project):
except Exception as exception:
logger.error('An Error occurred while sendin mail:')
logger.error(exception)
def send_registration_alert_mail(candidate, project):
''' sends a mail to an organizer after a user submitted his registration
'''
logger.info('Start sending Alert-Mail')
from_email = settings.EMAIL_HOST_USER
to_email = settings.ORGANIZATION_ADDRESS
subject = 'Neue Projektanmeldung auf Webseite'
context = {'forename': candidate.forename,
'surname': candidate.surname,
'groupname': project.name
}
msg_plain = render_to_string(
'ui/mail-templates/organization-alert-mail.txt', context)
msg_html = render_to_string(
'ui/mail-templates/organization-alert-mail.html', context)
try:
send_mail(subject, msg_plain, from_email, [
to_email], html_message=msg_html)
except Exception as exception:
logger.error('An Error occurred while sendin alert-mail:')
logger.error(exception)
<style>
h4 {
font-size: 17;
}
p {
font-size: 15;
margin: 0;
padding: 0;
}
.small-text {
font-size: 12;
}
</style>
<h4>Neue Anmeldung für Projekt {{ groupname }}</h4>
<p>Über das Webinterface ging eine neue Anmeldung ein! <br>
<b>{{ groupname }}</b><br>
<b>{{surname}}, {{forename}}</b><br>
</p>
<hr>
<p class="small-text">
Berliner Straße 1 <br>
D-71083 Herrenberg<br>
E-Mail: info@aerospace-lab.de<br>
Tel. 07032 78435 15<br>
Fax. 07032 78435 17<br>
<a href="https://aerospace-lab.de">www.aerospace-lab.de</a></p>
\ No newline at end of file
Neue Anmeldung für Projekt {{ groupname }}
Über das Webinterface ging eine neue Anmeldung ein!
{{ groupname }}
{{surname}}, {{forename}}
<p class="small-text">
Berliner Straße 1
D-71083 Herrenberg
E-Mail: info@aerospace-lab.de
Tel. 07032 78435 15
Fax. 07032 78435 17
<a href="https://aerospace-lab.de">www.aerospace-lab.de
\ No newline at end of file
......@@ -4,7 +4,7 @@ from datetime import date
from .models import Project
from .forms import RegisterForm, RegisterFormWithPrevMembership
from django.conf import settings
from .mailactions import send_registration_confirmation_mail
from .mailactions import send_registration_confirmation_mail, send_registration_alert_mail
# Create your views here.
......@@ -51,6 +51,7 @@ def show_project(request, project_id):
instance.project = project
instance.save()
send_registration_confirmation_mail(instance, project)
send_registration_alert_mail(instance, project)
return redirect('/project/{}/success'.format(project.project_id))
else:
form = select_form(project)
......
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