From 6155857dcd9a88d07756c465df42c5155c7183dc Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Fri, 10 Nov 2017 20:44:21 -0500 Subject: User registration works. User invites work but has no UI --- app/dispatchAuth/models.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'app/dispatchAuth/models.py') 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): -- cgit v1.2.3