diff options
Diffstat (limited to 'app/dispatchAuth')
| -rw-r--r-- | app/dispatchAuth/models.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/dispatchAuth/models.py b/app/dispatchAuth/models.py index 3132f1d..8173146 100644 --- a/app/dispatchAuth/models.py +++ b/app/dispatchAuth/models.py @@ -1,4 +1,6 @@ from django.contrib.auth.models import AbstractUser, AbstractBaseUser, PermissionsMixin, BaseUserManager +from app.settings import WEBSITE_URI +from django.template.loader import render_to_string from django.core.mail import send_mail from django.core.urlresolvers import reverse from django.db import models @@ -71,6 +73,17 @@ class User(PermissionsMixin, AbstractBaseUser): """Send an email to this user.""" send_mail(subject, message, from_email, [self.email], **kwargs) + def send_invite(self, name, to, from_email=None, **kwargs): + """Send an invite for a new user to register""" + current_site = WEBSITE_URI + message = render_to_string('dispatch/invite_email.txt', + { 'name': name, 'user': self, 'site': current_site }) + + send_mail("Invitation to register at {}".format(current_site), + message, + from_email, + [to]) + @property def is_staff(self): |
