UUID, email fields and receiver for sending them, /edit API for modifying signup with ID and UUID
This commit is contained in:
+14
-2
@@ -6,6 +6,8 @@ from django.core.mail import send_mail
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from django.conf import settings
|
||||
from django.template.loader import render_to_string
|
||||
from sikweb.settings import URL
|
||||
|
||||
|
||||
def month_from_now():
|
||||
@@ -13,17 +15,27 @@ def month_from_now():
|
||||
return timezone.now() + timedelta(days=30)
|
||||
|
||||
|
||||
def send_email(to, subject, body):
|
||||
def send_email(to, subject, body, fail_silently=False):
|
||||
try:
|
||||
success = send_mail(
|
||||
subject,
|
||||
body,
|
||||
settings.DEFAULT_EMAIL_FROM,
|
||||
[to],
|
||||
fail_silently=False,
|
||||
fail_silently=fail_silently,
|
||||
)
|
||||
if success == 0:
|
||||
raise Exception('Failed to send email!')
|
||||
|
||||
except Exception as ex:
|
||||
logging.exception('Failed to send email.')
|
||||
|
||||
|
||||
def send_signup_email(to, subject, id, uuid):
|
||||
message = render_to_string(
|
||||
'webapp:signup_email.html', {
|
||||
'url': f"https://{URL}/api/signup/{id}/edit/?uuid={uuid}",
|
||||
}
|
||||
)
|
||||
|
||||
return send_email(to, subject, message, fail_silently=True)
|
||||
|
||||
Reference in New Issue
Block a user