Skip to content

Commit

Permalink
Add CR email
Browse files Browse the repository at this point in the history
  • Loading branch information
didrikmunther committed Aug 4, 2024
1 parent 8694445 commit 7bda927
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 61 deletions.
65 changes: 65 additions & 0 deletions dashboard/api/registration/email.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import datetime

from ais.common import settings
from util.email import send_mail


def send_ir_confirmation_email(
request,
fair,
signature,
company,
# How many days the company has to change their initial registration application after signing the contract
ir_application_change_allowed_time=14,
# How many days after the initial registration end date the company will receive a confirmation email
ir_application_review_time=14,
):
# The deadline for the company to change their initial registration application
# either x days after signature, or the registration end date, whichever comes last.
ir_application_change_deadline = max(
[
signature.timestamp
+ datetime.timedelta(days=ir_application_change_allowed_time),
fair.registration_end_date,
]
)

# The latest date the company will receive a confirmation email
ir_application_review_date = fair.registration_end_date + datetime.timedelta(
days=ir_application_review_time
)

send_mail(
request,
template="register/email/ir_complete.html",
context={
"company": company,
"fair": fair,
"signature": signature,
"ir_application_change_deadline": ir_application_change_deadline,
"ir_application_review_date": ir_application_review_date,
"support_email": "[email protected]",
},
subject="Initial registration received!",
to=[signature.company_contact.email_address],
file_paths=[settings.MEDIA_ROOT + signature.contract.contract.url[6:]],
)


def send_cr_confirmation_email(request, fair, company, exhibitor, signature):
# Untested
# Todo: Add packages to email
send_mail(
request,
template="register/email/cr_complete.html",
context={
"company": company,
"fair": fair,
"signature": signature,
"deadline": exhibitor.deadline_complete_registration
or fair.complete_registration_close_date,
},
subject="Final registration received!",
to=[signature.company_contact.email_address],
file_paths=[settings.MEDIA_ROOT + signature.contract.contract.url[6:]],
)
66 changes: 5 additions & 61 deletions dashboard/api/registration/response.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import datetime
from ais.common import settings
from dashboard.api.registration.email import (
send_cr_confirmation_email,
send_ir_confirmation_email,
)
from dashboard.api.registration.types.registration import get_registration
from exhibitors.models import Exhibitor
from util import JSONError, get_contract_signature, get_exhibitor, status
Expand All @@ -12,7 +14,6 @@
from register.models import SignupLog
from accounting.models import Order

from util.email import send_mail
from util.ip import get_client_ip


Expand Down Expand Up @@ -80,22 +81,7 @@ def submit_cr(request, company, fair, contact, exhibitor):
unit_price=0, # A package product is free
)

# Untested
# Todo: Add packages to email
send_mail(
request,
template="register/email/cr_complete.html",
context={
"company": company,
"fair": fair,
"signature": signature,
"deadline": exhibitor.deadline_complete_registration
or fair.complete_registration_close_date,
},
subject="Final registration received!",
to=[signature.company_contact.email_address],
file_paths=[settings.MEDIA_ROOT + signature.contract.contract.url[6:]],
)
send_cr_confirmation_email(request, fair, company, exhibitor, signature)

try:
registration = get_registration(company, fair, contact, exhibitor)
Expand All @@ -107,48 +93,6 @@ def submit_cr(request, company, fair, contact, exhibitor):
return JsonResponse(serializer.data, safe=False)


def send_ir_confirmation_email(
request,
fair,
signature,
company,
# How many days the company has to change their initial registration application after signing the contract
ir_application_change_allowed_time=14,
# How many days after the initial registration end date the company will receive a confirmation email
ir_application_review_time=14,
):
# The deadline for the company to change their initial registration application
# either x days after signature, or the registration end date, whichever comes last.
ir_application_change_deadline = max(
[
signature.timestamp
+ datetime.timedelta(days=ir_application_change_allowed_time),
fair.registration_end_date,
]
)

# The latest date the company will receive a confirmation email
ir_application_review_date = fair.registration_end_date + datetime.timedelta(
days=ir_application_review_time
)

send_mail(
request,
template="register/email/ir_complete.html",
context={
"company": company,
"fair": fair,
"signature": signature,
"ir_application_change_deadline": ir_application_change_deadline,
"ir_application_review_date": ir_application_review_date,
"support_email": "[email protected]",
},
subject="Initial registration received!",
to=[signature.company_contact.email_address],
file_paths=[settings.MEDIA_ROOT + signature.contract.contract.url[6:]],
)


@require_POST
def submit_ir(request, company, fair, contact):
try:
Expand Down
1 change: 1 addition & 0 deletions templates/register/email/cr_complete.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<p style="font-size:16px;line-height:24px;margin:16px 0;color:#525f7f;text-align:left">
The complete registration is binding and you will be liable for all additional services selected at the last date of the registration
({{ deadline|date:"Y-m-d" }}), provided that THS Armada is able to supply your organization with your choices. To view your order, please visit the dashboard.
</p>
{% include 'email/button.html' with content="Go to dashboard" url="https://ais.armada.nu/register" %}
{% include 'email/divider.html' %}
<p style="font-size:16px;line-height:24px;margin:16px 0;color:#525f7f;text-align:left">
Expand Down

0 comments on commit 7bda927

Please sign in to comment.