aboutsummaryrefslogtreecommitdiff
path: root/app/dispatchAuth
diff options
context:
space:
mode:
Diffstat (limited to 'app/dispatchAuth')
-rw-r--r--app/dispatchAuth/admin.py4
-rw-r--r--app/dispatchAuth/forms.py11
-rw-r--r--app/dispatchAuth/models.py6
3 files changed, 19 insertions, 2 deletions
diff --git a/app/dispatchAuth/admin.py b/app/dispatchAuth/admin.py
index 38ec7a6..d65390c 100644
--- a/app/dispatchAuth/admin.py
+++ b/app/dispatchAuth/admin.py
@@ -1,7 +1,7 @@
from django import forms
from django.contrib import admin
from django.contrib.auth.models import Group
-from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
+from django.contrib.auth.admin import UserAdmin as BaseUserAdmin, UserAdmin
from django.contrib.auth.forms import ReadOnlyPasswordHashField
# Register your models here.
@@ -55,7 +55,7 @@ class UserChangeForm(forms.ModelForm):
return self.initial["password"]
-class UserAdmin(BaseUserAdmin):
+class UserAdmin(UserAdmin):
# The forms to add and change user instances
form = UserChangeForm
add_form = UserCreationForm
diff --git a/app/dispatchAuth/forms.py b/app/dispatchAuth/forms.py
new file mode 100644
index 0000000..99781f7
--- /dev/null
+++ b/app/dispatchAuth/forms.py
@@ -0,0 +1,11 @@
+from registration.forms import RegistrationForm
+from .models import User
+
+
+class UserForm(RegistrationForm):
+ # fields = ['email', 'first_name', 'last_name']
+ # model = User
+
+ class Meta:
+ fields = ['email', 'first_name', 'last_name']
+ model = User
diff --git a/app/dispatchAuth/models.py b/app/dispatchAuth/models.py
index 49e0a41..3132f1d 100644
--- a/app/dispatchAuth/models.py
+++ b/app/dispatchAuth/models.py
@@ -1,4 +1,5 @@
from django.contrib.auth.models import AbstractUser, AbstractBaseUser, PermissionsMixin, BaseUserManager
+from django.core.mail import send_mail
from django.core.urlresolvers import reverse
from django.db import models
@@ -66,6 +67,11 @@ class User(PermissionsMixin, AbstractBaseUser):
def __str__(self):
return self.email
+ def email_user(self, subject, message, from_email=None, **kwargs):
+ """Send an email to this user."""
+ send_mail(subject, message, from_email, [self.email], **kwargs)
+
+
@property
def is_staff(self):
return self.is_superuser