implemented new email templates, but not rendering
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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])
|
||||
|
||||
197
templates/purchase_contact_confirmation.html
Normal file → Executable file
197
templates/purchase_contact_confirmation.html
Normal file → Executable file
@@ -1,10 +1,197 @@
|
||||
Hola usuario.
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||
|
||||
Hemos envíado correctamente el siguiente email a la empresa {{company}} sobre el producto {{product}}:
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;700&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<title>Interés en copra de producto</title>
|
||||
<style>
|
||||
.body {
|
||||
color: #374493;
|
||||
font-family: 'Poppins', sans-serif;
|
||||
background-color: #8cead8;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.mail {
|
||||
margin: 50px auto;
|
||||
width: 60%;
|
||||
padding: 30px;
|
||||
background-color: white;
|
||||
border-radius: 5px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
{{company_message}}
|
||||
.header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-content: center;
|
||||
}
|
||||
.latienda-logo {
|
||||
max-width: 300px;
|
||||
margin: auto;
|
||||
}
|
||||
.title {
|
||||
font-size: 1.5rem;
|
||||
text-align: center;
|
||||
margin-top: 60px;
|
||||
padding-bottom: 5px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-content: center;
|
||||
padding: 0 30px 30px 30px;
|
||||
}
|
||||
.product-data {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
max-width: 400px;
|
||||
margin: auto;
|
||||
margin-bottom: 20px;
|
||||
font-weight: 400;
|
||||
}
|
||||
.text {
|
||||
text-align: justify;
|
||||
font-size: 1.2rem;
|
||||
padding: 3px;
|
||||
margin-top: 40px;
|
||||
max-width: 300px;
|
||||
hyphens: auto;
|
||||
}
|
||||
|
||||
.coop-name {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
Deberías recibir una respuesta directa en los próximos días.
|
||||
.product-image {
|
||||
max-width: 250px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
LaTiendaCOOP
|
||||
.product-link {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.product-price {
|
||||
font-weight: 700;
|
||||
}
|
||||
.coop-info {
|
||||
max-width: fit-content;
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
.coop-data {
|
||||
font-size: 1.2rem;
|
||||
margin-top: 20px;
|
||||
font-family: 'Noto Sans', sans-serif;
|
||||
align-self: left;
|
||||
}
|
||||
.coop-image {
|
||||
max-width: 120px;
|
||||
margin: auto;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.name {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 700;
|
||||
display: inline;
|
||||
}
|
||||
.value {
|
||||
margin: 0;
|
||||
display: inline;
|
||||
font-weight: 400;
|
||||
}
|
||||
@media all and (min-width:780px) {
|
||||
.mail {
|
||||
width: 40%;
|
||||
}
|
||||
}
|
||||
@media all and (max-width: 780px) {
|
||||
.title {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
.text {
|
||||
font-size: 1rem;
|
||||
}
|
||||
h2 {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
.value, .name {
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="body">
|
||||
<div class="mail">
|
||||
<header class="header">
|
||||
<a href="https://latienda.coop/" target="_blank">
|
||||
<img
|
||||
src="https://latienda.coop/_nuxt/img/latienda-logo.3e53761.svg"
|
||||
alt=""
|
||||
class="latienda-logo"
|
||||
/>
|
||||
</a>
|
||||
<h1 class="title">
|
||||
<span>Confirmación de</span>
|
||||
<span>solicitud enviada</span>
|
||||
</h1>
|
||||
</header>
|
||||
<main class="main">
|
||||
|
||||
<div class="product-data">
|
||||
<a
|
||||
href="https://latiendacoop.s3.amazonaws.com/products/0101UNADEGATOBERMEJO.jpeg"
|
||||
target="_blank"
|
||||
>
|
||||
<img
|
||||
src="https://latiendacoop.s3.amazonaws.com/products/0101UNADEGATOBERMEJO.jpeg"
|
||||
alt=""
|
||||
class="product-image"
|
||||
/>
|
||||
</a>
|
||||
<a
|
||||
href="https://latienda.coop/productos/356"
|
||||
class="product-link"
|
||||
>Enlace al producto</a
|
||||
>
|
||||
<span class="product-name">Nombre del producto: {{product.name}}</span>
|
||||
<span class="product-id-sku">{{product.sku}}</span>
|
||||
<span class="product-price">{{product.price}}</span>
|
||||
<p class="text">¡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 <span class="coop-name">{{company.short_name}}</span>.</p>
|
||||
</div>
|
||||
<div class="coop-info">
|
||||
<h2>Contacto cooperativa</h2>
|
||||
<dl class="coop-data">
|
||||
<dt class="name">Nombre:</dt>
|
||||
<dd class="value">{{manager.full_name}}<br /></dd>
|
||||
<dt class="name">Email:</dt>
|
||||
<dd class="value">{{company.email}}<br /></dd>
|
||||
</dd>
|
||||
</dl>
|
||||
<a href="https://pol-len.cat/" target="_blank">
|
||||
<img class="coop-image" src="https://latiendacoop.s3.amazonaws.com/logos/pollen-logo.png" target="_blank" alt="">
|
||||
</a>
|
||||
</div>
|
||||
</main>
|
||||
<footer class="footer">
|
||||
<span>2021 La Tienda.Coop</span>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
180
templates/purchase_notification.html
Normal file → Executable file
180
templates/purchase_notification.html
Normal file → Executable file
@@ -1,9 +1,175 @@
|
||||
Hola {{company}}.
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||
|
||||
El usuario {{user.email}} ha mostrado interés en la compra del producto {{product}}.
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;700&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<title>Interés en copra de producto</title>
|
||||
<style>
|
||||
.body {
|
||||
color: #374493;
|
||||
font-family: 'Poppins', sans-serif;
|
||||
background-color: #8cead8;
|
||||
}
|
||||
.mail {
|
||||
margin: 50px auto;
|
||||
width: 60%;
|
||||
padding: 30px;
|
||||
min-height: 400px;
|
||||
background-color: white;
|
||||
border-radius: 5px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
Ponte en contacto con el usuario tan pronto como te sea posible para finalizar la venta.
|
||||
|
||||
Teléfono de contacto: {{telephone}}
|
||||
|
||||
LaTiendaCOOP
|
||||
.header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-content: center;
|
||||
}
|
||||
.latienda-logo {
|
||||
max-width: 300px;
|
||||
margin: auto;
|
||||
}
|
||||
.title {
|
||||
font-size: 1.5rem;
|
||||
text-align: center;
|
||||
margin-top: 60px;
|
||||
padding-bottom: 5px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-content: center;
|
||||
padding: 0 30px 30px 30px;
|
||||
}
|
||||
.product-data {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
max-width: 400px;
|
||||
margin: auto;
|
||||
margin-bottom: 20px;
|
||||
font-weight: 400;
|
||||
}
|
||||
.product-image {
|
||||
max-width: 250px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.product-link {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.product-price {
|
||||
font-weight: 700;
|
||||
}
|
||||
.client-info {
|
||||
max-width: fit-content;
|
||||
}
|
||||
.client-data {
|
||||
font-size: 1.2rem;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 50px;
|
||||
font-family: 'Noto Sans', sans-serif;
|
||||
align-self: left;
|
||||
}
|
||||
.name {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 700;
|
||||
display: inline;
|
||||
}
|
||||
.value {
|
||||
margin: 0;
|
||||
display: inline;
|
||||
font-weight: 400;
|
||||
}
|
||||
@media all and (min-width: 780px) {
|
||||
.mail {
|
||||
width: 40%;
|
||||
}
|
||||
}
|
||||
@media all and (max-width: 780px) {
|
||||
.title {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
h2 {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
.value,
|
||||
.name {
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="body">
|
||||
<div class="mail">
|
||||
<header class="header">
|
||||
<a href="https://latienda.coop/" target="_blank">
|
||||
<img
|
||||
src="https://latienda.coop/_nuxt/img/latienda-logo.3e53761.svg"
|
||||
alt=""
|
||||
class="latienda-logo"
|
||||
/>
|
||||
</a>
|
||||
<h1 class="title">
|
||||
<span>Interés en compra</span>
|
||||
<span>de producto</span>
|
||||
</h1>
|
||||
</header>
|
||||
<main class="main">
|
||||
<div class="product-data">
|
||||
<a
|
||||
href="https://latiendacoop.s3.amazonaws.com/products/0101UNADEGATOBERMEJO.jpeg"
|
||||
target="_blank"
|
||||
>
|
||||
<img
|
||||
src="https://latiendacoop.s3.amazonaws.com/products/0101UNADEGATOBERMEJO.jpeg"
|
||||
alt=""
|
||||
class="product-image"
|
||||
/>
|
||||
</a>
|
||||
<a
|
||||
href="https://latienda.coop/productos/356"
|
||||
class="product-link"
|
||||
>Enlace al producto</a
|
||||
>
|
||||
<span class="product-name">Nombre del producto: {{product.name}}</span>
|
||||
<span class="product-id-sku">{{product.sku}}</span>
|
||||
<span class="product-price">{{product.price}}</span>
|
||||
</div>
|
||||
<div class="client-info">
|
||||
<h2>Datos cliente</h2>
|
||||
<dl class="client-data">
|
||||
<dt class="name">Nombre:</dt>
|
||||
<dd class="value">{{user.full_name}}<br /></dd>
|
||||
<dt class="name">Email:</dt>
|
||||
<dd class="value">{{user.email}}<br /></dd>
|
||||
<dt class="name">Teléfono:</dt>
|
||||
<dd class="value">{{telephone}}<br /></dd>
|
||||
<dt class="name">Comentarios:</dt>
|
||||
<dd class="value">{{comment}}<br/>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</main>
|
||||
<footer class="footer">
|
||||
<span>2021 La Tienda.Coop</span>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user