Commit f29ac4eb authored by William Colmenares's avatar William Colmenares

Added sending welcome email on user registration

parent 8fff4603
......@@ -96,7 +96,25 @@ class Register(View):
return render(request, 'error.html', { 'urlname': urlname,
'service': service,
'error': e } )
# Finally, we send the send user credentials via email
creationtime = int(datetime.utcnow().timestamp())
# Construct the data for the email
email_from = settings.EMAIL_FROM_ADDRESS
to = ['%s <%s>' % (username, email)]
subject = '{}, Welcome to datacenterlight'.format(firstname)
body = 'The username {} was successfully created.\n'.format(username)
# Build the email
mail = EmailMessage(
subject=subject,
body=body,
from_email=email_from,
to=to
)
try:
mail.send()
except Exception as e:
print(e)
pass
return render(request, 'usercreated.html', { 'user': username } )
class ChangeData(LoginRequiredMixin, View):
......@@ -466,6 +484,9 @@ class PseudoUser():
class UserCreateAPI(APIView):
def post(self, request):
print(request.data)
print(request.POST)
username = request.POST.get('username')
email = request.POST.get('email')
firstname = request.POST.get('firstname')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment