diff --git a/products/tests.py b/products/tests.py
index d9db3ea..6efa7dd 100644
--- a/products/tests.py
+++ b/products/tests.py
@@ -1217,8 +1217,13 @@ class PurchaseEmailTest(APITestCase):
self.assertEquals(2, len(mail.outbox))
def test_auth_user_can_use(self):
+ # required instances
company = CompanyFactory()
product = ProductFactory(company=company)
+ # make user the manager
+ self.user.company = company
+ self.user.role = 'COOP_MANAGER'
+ self.user.save()
data = {
'telephone': '123123123',
diff --git a/products/views.py b/products/views.py
index 4e132ae..f75efdb 100644
--- a/products/views.py
+++ b/products/views.py
@@ -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])
diff --git a/templates/purchase_contact_confirmation.html b/templates/purchase_contact_confirmation.html
old mode 100644
new mode 100755
index 7d5deb6..32652ff
--- a/templates/purchase_contact_confirmation.html
+++ b/templates/purchase_contact_confirmation.html
@@ -1,10 +1,197 @@
-Hola usuario.
+
+
+
+
+
+
+
+
+
-Hemos envíado correctamente el siguiente email a la empresa {{company}} sobre el producto {{product}}:
+
+ Interés en copra de producto
+
+
+
+
+
+
+
+ Enlace al producto
+ Nombre del producto: {{product.name}}
+ {{product.sku}}
+ {{product.price}}
+
¡Hola! Tu solicitud de compra de este producto ha sido comunicado a la cooperativa. Pronto tendrás noticias suyas. Para cualquier duda o asistencia, ponte en contacto con {{company.short_name}}.