mirror of
https://github.com/fspc/workstand.git
synced 2026-09-16 16:41:38 -04:00
Initial commit.
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
@@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class RegistrationConfig(AppConfig):
|
||||
name = 'registration'
|
||||
@@ -0,0 +1,49 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.4 on 2016-03-23 01:25
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('auth', '0007_alter_validators_add_error_messages'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Member',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('password', models.CharField(max_length=128, verbose_name='password')),
|
||||
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
|
||||
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
|
||||
('email', models.EmailField(max_length=255, unique=True, verbose_name='email address')),
|
||||
('first_name', models.CharField(max_length=255)),
|
||||
('last_name', models.CharField(max_length=255)),
|
||||
('preferred_name', models.CharField(blank=True, max_length=255, null=True)),
|
||||
('date_of_birth', models.DateField(blank=True, null=True)),
|
||||
('guardian_name', models.CharField(blank=True, max_length=255, null=True)),
|
||||
('phone', models.CharField(blank=True, max_length=20, null=True)),
|
||||
('street', models.CharField(blank=True, max_length=255, null=True)),
|
||||
('city', models.CharField(blank=True, max_length=255, null=True)),
|
||||
('province', models.CharField(blank=True, max_length=255, null=True)),
|
||||
('country', models.CharField(blank=True, max_length=255, null=True)),
|
||||
('post_code', models.CharField(blank=True, max_length=20, null=True)),
|
||||
('self_identification', models.CharField(blank=True, max_length=255, null=True)),
|
||||
('gender', models.CharField(blank=True, max_length=255, null=True)),
|
||||
('involvement', models.CharField(blank=True, max_length=255, null=True)),
|
||||
('waiver', models.DateTimeField(blank=True, null=True)),
|
||||
('is_active', models.BooleanField(default=True)),
|
||||
('is_admin', models.BooleanField(default=False)),
|
||||
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
|
||||
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,87 @@
|
||||
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, PermissionsMixin
|
||||
from django.db import models
|
||||
|
||||
|
||||
class CustomMemberManager(BaseUserManager):
|
||||
def create_user(self, email, first_name, last_name, password=None):
|
||||
"""
|
||||
Creates and saves a User with the given email and password.
|
||||
:param email: str
|
||||
:param password: str
|
||||
:param first_name: str
|
||||
:param last_name: str
|
||||
:return: object `CustomUser`
|
||||
"""
|
||||
if not email:
|
||||
raise ValueError('Users must have an email address')
|
||||
|
||||
user = self.model(
|
||||
email=self.normalize_email(email),
|
||||
)
|
||||
|
||||
user.set_password(password)
|
||||
user.save(using=self._db)
|
||||
return user
|
||||
|
||||
def create_superuser(self, email, password):
|
||||
"""
|
||||
Creates and saves a superuser with the given email, date of
|
||||
birth and password.
|
||||
:param email: str
|
||||
:param password: str
|
||||
:return: object `CustomUser`
|
||||
"""
|
||||
user = self.create_user(email, password=password)
|
||||
user.is_admin = True
|
||||
user.is_superuser = True
|
||||
user.save(using=self._db)
|
||||
return user
|
||||
|
||||
|
||||
class Member(AbstractBaseUser, PermissionsMixin):
|
||||
email = models.EmailField(
|
||||
verbose_name='email address',
|
||||
max_length=255,
|
||||
unique=True,
|
||||
)
|
||||
first_name = models.CharField(max_length=255, null=False)
|
||||
last_name = models.CharField(max_length=255, null=False)
|
||||
preferred_name = models.CharField(max_length=255, null=True, blank=True)
|
||||
date_of_birth = models.DateField(null=True, blank=True)
|
||||
guardian_name = models.CharField(max_length=255, null=True, blank=True)
|
||||
phone = models.CharField(max_length=20, null=True, blank=True)
|
||||
street = models.CharField(max_length=255, null=True, blank=True)
|
||||
city = models.CharField(max_length=255, null=True, blank=True)
|
||||
province = models.CharField(max_length=255, null=True, blank=True)
|
||||
country = models.CharField(max_length=255, null=True, blank=True)
|
||||
post_code = models.CharField(max_length=20, null=True, blank=True)
|
||||
self_identification = models.CharField(max_length=255, null=True, blank=True)
|
||||
gender = models.CharField(max_length=255, null=True, blank=True)
|
||||
involvement = models.CharField(max_length=255, null=True, blank=True)
|
||||
waiver = models.DateTimeField(null=True, blank=True)
|
||||
is_active = models.BooleanField(default=True)
|
||||
is_admin = models.BooleanField(default=False)
|
||||
|
||||
objects = CustomMemberManager()
|
||||
|
||||
USERNAME_FIELD = 'email'
|
||||
# REQUIRED_FIELDS = []
|
||||
|
||||
def get_full_name(self):
|
||||
# The user is identified by their email address
|
||||
if self.first_name and self.last_name:
|
||||
return '{0} {1}'.format(self.first_name, self.last_name)
|
||||
else:
|
||||
return self.email
|
||||
|
||||
def get_short_name(self):
|
||||
# The user is identified by their email address
|
||||
return self.email
|
||||
|
||||
def __str__(self): # __unicode__ on Python 2
|
||||
return self.email
|
||||
|
||||
@property
|
||||
def is_staff(self):
|
||||
# Simplest possible answer: All admins are staff
|
||||
return self.is_admin
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
Reference in New Issue
Block a user