351c9cd955
- Deleted multiple unused image files from the static media directory. - Enhanced email sending functionality by adding a new method `send_hemail` for sending HTML emails. - Updated the `enviar_correo_bienvenida` task to use the new HTML email method. - Added a new RGPD (General Data Protection Regulation) privacy policy page template. - Updated URL routing to include the new RGPD page. - Added a view function for rendering the RGPD page.
29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
from celery import shared_task
|
|
from django.conf import settings
|
|
from django.template.loader import render_to_string
|
|
from .utilities import send_email, send_hemail
|
|
from .vars import login_message, verify_message
|
|
import random, string
|
|
|
|
from .models import User, VerificationCode
|
|
@shared_task
|
|
def enviar_correo_bienvenida(email_usuario: str, nombre_usuario: str):
|
|
html_content = render_to_string(
|
|
'emails/welcome.html',
|
|
{
|
|
"name": nombre_usuario
|
|
},
|
|
using='jinja2'
|
|
)
|
|
send_hemail(email_usuario, "Inicio de Sesión correcto", html_content, "Has iniciado sesión...")
|
|
|
|
@shared_task
|
|
def enviar_correo_confirmacion(usuario: User):
|
|
code = VerificationCode.objects.create(
|
|
user = usuario,
|
|
code_mode = VerificationCode.VerificationModes.VERIFY_ACCOUNT,
|
|
code = ''.join(random.choices(string.digits, k=12))
|
|
)
|
|
|
|
message = verify_message.format(name = usuario.get_full_name(), protocol = settings.PROTOCOL, domain = settings.DOMAIN, code = code.code)
|
|
email_result = send_email(usuario.email, "Verificación de cuenta", message) |