improvements to email templates

This commit is contained in:
Sam
2021-02-10 10:43:26 +00:00
parent 202369e189
commit 25231b3b16
3 changed files with 22 additions and 1 deletions

View File

@@ -29,6 +29,7 @@ class CompanyViewSet(viewsets.ModelViewSet):
"""
Send email to company.creator
"""
# TODO: check access for anonymous users, and customize response
queryset = self.get_custom_queryset(request)
instance = queryset.filter(pk=kwargs['pk']).first()
@@ -36,6 +37,7 @@ class CompanyViewSet(viewsets.ModelViewSet):
data = json.loads(request.body)
# send email to manager
message = render_to_string('company_contact.html', {
'company': instance,
'user': request.user,
'data': data,
})
@@ -45,11 +47,15 @@ class CompanyViewSet(viewsets.ModelViewSet):
# send confirmation email to user
message = render_to_string('confirm_company_contact.html', {
'company': instance,
'user': request.user,
'data': data,
})
email = EmailMessage(subject, message, to=[request.user.email])
email.send()
logging.info(f"Confirmation email sent to {request.user.email}")
logging.info(f"contact Confirmation email sent to {request.user.email}")
# TODO: create statslog instance to rgister interaction
return Response(data=data)
else: