Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send an email for newly enrolled members #800

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions amelie/members/templates/members/new_member.mail
Original file line number Diff line number Diff line change
@@ -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 %}
27 changes: 27 additions & 0 deletions amelie/members/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand All @@ -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

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()))

Expand Down
Loading