implemented new email templates, but not rendering
This commit is contained in:
@@ -273,10 +273,16 @@ def purchase_email(request):
|
||||
validate_email(user_email)
|
||||
except:
|
||||
return Response({"error": "Value for email is not valid"}, status=status.HTTP_406_NOT_ACCEPTABLE)
|
||||
# get comment
|
||||
comment = data.get('comment')
|
||||
# get company
|
||||
company = Company.objects.filter(id=data['company']).first()
|
||||
if not company:
|
||||
return Response({"error": "Invalid value for company"}, status=status.HTTP_406_NOT_ACCEPTABLE)
|
||||
# get managing user
|
||||
managing_user = User.objects.filter(company=company, role='COOP_MANAGER').first()
|
||||
if not managing_user:
|
||||
return Response({"error": "No managing user found for company"}, status=status.HTTP_406_NOT_ACCEPTABLE)
|
||||
# get product
|
||||
product = Product.objects.filter(id=data['product'], company=company).first()
|
||||
if not product:
|
||||
@@ -291,6 +297,7 @@ def purchase_email(request):
|
||||
'user': request.user,
|
||||
'product': product,
|
||||
'telephone': data['telephone'],
|
||||
'comment': comment,
|
||||
})
|
||||
subject = "[latienda.coop] Solicitud de compra"
|
||||
email = EmailMessage(subject, company_message, to=[company.email])
|
||||
@@ -301,6 +308,7 @@ def purchase_email(request):
|
||||
'company': company,
|
||||
'product': product,
|
||||
'company_message': company_message,
|
||||
'manager': managing_user,
|
||||
})
|
||||
subject = 'Confirmación de petición de compra'
|
||||
email = EmailMessage(subject, user_message, to=[user_email])
|
||||
|
||||
Reference in New Issue
Block a user