diff --git a/amelie/members/templates/members/new_member.mail b/amelie/members/templates/members/new_member.mail new file mode 100644 index 0000000..251a148 --- /dev/null +++ b/amelie/members/templates/members/new_member.mail @@ -0,0 +1,12 @@ +{% extends "iamailer/email_basic.mail" %} +{% load i18n htmlify only %} + +{% block subject %}{% blocktrans %}[Inter-Actief] Welcome human!{% endblocktrans %}{% endblock %} + +{% block content %}{% htmlify %}{% blocktrans %}Dear{% endblocktrans %} {{ recipient.first_name }}, + +{% blocktrans %}Hereby, Vadim would like to welcome you to our beautiful association. May the cookie corner credit be in your favour.{% endblocktrans %} + +{% blocktrans %}Kind regards, + +The board of Inter-Actief{% endblocktrans %}{% endhtmlify %}{% endblock %} diff --git a/amelie/members/views.py b/amelie/members/views.py index 8ffc78f..70601ce 100644 --- a/amelie/members/views.py +++ b/amelie/members/views.py @@ -31,6 +31,7 @@ from django.views.generic.edit import DeleteView, FormView from amelie.claudia.models import Mapping, ExtraPerson +from amelie.iamailer import MailTask from amelie.members.forms import PersonDataForm, StudentNumberForm, \ RegistrationFormPersonalDetails, RegistrationFormStepMemberContactDetails, \ RegistrationFormStepParentsContactDetails, RegistrationFormStepFreshmenStudyDetails, \ @@ -48,6 +49,7 @@ from amelie.tools.encodings import normalize_to_ascii from amelie.tools.http import HttpResponseSendfile, HttpJSONResponse from amelie.tools.logic import current_academic_year_with_holidays, current_association_year +from amelie.tools.mail import PersonRecipient from amelie.tools.mixins import DeleteMessageMixin, RequireBoardMixin from amelie.tools.pdf import pdf_separator_page, pdf_membership_page, pdf_authorization_page @@ -392,6 +394,17 @@ def person_anonymize(request, id, slug): return render(request, 'person_anonymization_success.html', {'person': person}) +def send_new_member_email(person: Person): + """ + Send an email to a new member. This function is used for each type of member. + """ + template_name = "members/new_member.mail" + task = MailTask(template_name=template_name) + task.add_recipient(PersonRecipient(person, context={'membership': person.membership})) + + task.send() + + class RegisterNewGeneralWizardView(RequireBoardMixin, SessionWizardView): template_name = "person_registration_form_general.html" form_list = [RegistrationFormPersonalDetails, RegistrationFormStepMemberContactDetails, @@ -500,6 +513,9 @@ def done(self, form_list, **kwargs): begin=datetime.date(cleaned_data['generation'], 9, 1)) study_period.save() + # Send an email confirming the new enrolment + send_new_member_email(person) + # Render the enrollment forms to PDF for printing from amelie.tools.pdf import pdf_enrollment_form buffer = BytesIO() @@ -609,6 +625,9 @@ def done(self, form_list, **kwargs): link_code = get_oauth_link_code(person) send_oauth_link_code_email(self.request, person, link_code) + # Send an email confirming the new enrolment + send_new_member_email(person) + # Render the enrollment forms to PDF for printing from amelie.tools.pdf import pdf_enrollment_form buffer = BytesIO() @@ -716,6 +735,9 @@ def done(self, form_list, **kwargs): employee = Employee(person=person, number=cleaned_data['employee_number']) employee.save() + # Send an email confirming the new enrolment + send_new_member_email(person) + # Render the enrollment forms to PDF for printing from amelie.tools.pdf import pdf_enrollment_form buffer = BytesIO() @@ -838,6 +860,9 @@ def done(self, form_list, **kwargs): dogroup=cleaned_data['dogroup']) study_period.save() + # Send an email confirming the new enrolment + send_new_member_email(person) + # Render the enrollment forms to PDF for printing from amelie.tools.pdf import pdf_enrollment_form buffer = BytesIO() @@ -1073,6 +1098,8 @@ def get(self, request, *args, **kwargs): # Delete the pre-enrollment pre_enrollment.delete() + send_new_member_email(person) + # Set message messages.info(self.request, "Pre-registration of {} activated!".format(person.incomplete_name()))