myauth: send email after user completes registration

remotes/origin/license
Andrey 9 years ago
parent 66b7c81f08
commit 277bf17448
  1. 12
      project/myauth/emails.py
  2. 1
      project/myauth/views.py
  3. 7
      project/templates/myauth/welcome_email.txt

@ -2,6 +2,7 @@
from django.template.loader import render_to_string
from django.core.mail import EmailMessage
from django.conf import settings
from celery.decorators import task
@ -19,6 +20,17 @@ def send_registration_email(user_email, confirm_url):
return email.send()
@task
def send_welcome_email(user_email):
"""Отправить приветственное письмо."""
template_name = 'myauth/welcome_email.txt'
subject = u'Добро пожаловать на Документор!'
dict_context = {'support_email': SUPPORT_EMAIL,}
email_body = render_to_string(template_name, dict_context)
email = EmailMessage(subject=subject, to=(user_email,), body=email_body)
return email.send()
@task
def send_reset_password_email(user_email, confirm_url):
"""Отправить письмо с ключём для восстановления пароля."""

@ -97,6 +97,7 @@ def confirm_registered_email(request, key):
any_licenses = License.objects.filter(company=user.profile).exists()
if not any_licenses:
license = License.objects.create_test_period_license(company=user.profile)
emails.send_welcome_email.delay(new_user.email, confirm_url)
user.profile.confirmed = True
user.profile.active = True
user.profile.save()

@ -0,0 +1,7 @@
Здравствуйте!
Приветствуем вас на Документоре.
Это письмо написано роботом. Отвечать на него не нужно.
Связаться со службой поддержки сайта Документор Вы можете по адресу {{ support_email }}
Loading…
Cancel
Save