-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
auth by email only, select field added
- Loading branch information
Showing
20 changed files
with
251 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,4 +40,4 @@ ignore = | |
B007, | ||
B950, | ||
|
||
max-line-length = 200 | ||
max-line-length = 119 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. | ||
|
||
from .models import User | ||
admin.site.register(User) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,21 @@ | ||
from django.contrib.auth.models import User | ||
from accounts.models import User | ||
from django import forms | ||
from django.contrib.auth.forms import UserCreationForm, UserChangeForm | ||
|
||
|
||
class LoginForm(forms.Form): | ||
username = forms.CharField(max_length=63) | ||
password = forms.CharField(max_length=63, widget=forms.PasswordInput) | ||
email = forms.EmailField(max_length=100) | ||
password = forms.CharField(max_length=63, widget=forms.PasswordInput) | ||
|
||
|
||
class EditProfileForm(UserChangeForm): | ||
password = forms.CharField(label="", widget=forms.TextInput(attrs={'type':'hidden'})) | ||
class Meta: | ||
model = User | ||
fields = ('username', 'first_name', 'last_name', 'email','password',) | ||
fields = ('email','name','password') | ||
|
||
|
||
|
||
|
||
class SignUpForm(UserCreationForm): | ||
class Meta: | ||
model = User | ||
fields = ('username', 'email', 'password1', 'password2',) | ||
fields = ('email', 'password1', 'password2',) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from django.contrib.auth.base_user import BaseUserManager | ||
|
||
|
||
class UserManager(BaseUserManager): | ||
use_in_migrations = True | ||
|
||
def _create_user(self, email, password, **extra_fields): | ||
""" | ||
Creates and saves a User with the given email and password. | ||
""" | ||
if not email: | ||
raise ValueError('Users must have an email address') | ||
# username = self.normalize_email(username) | ||
user = self.model(email=email, **extra_fields) | ||
user.set_password(password) | ||
user.save(using=self._db) | ||
return user | ||
|
||
def create_user(self, email, password=None, **extra_fields): | ||
extra_fields.setdefault('is_superuser', False) | ||
return self._create_user(email, password, **extra_fields) | ||
|
||
def create_superuser(self, email, password, **extra_fields): | ||
extra_fields.setdefault('is_staff', True) | ||
extra_fields.setdefault('is_superuser', True) | ||
extra_fields.setdefault('is_active', True) | ||
|
||
if extra_fields.get('is_superuser') is not True: | ||
raise ValueError('Superuser must have is_superuser=True.') | ||
|
||
return self._create_user(email, password, **extra_fields) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Generated by Django 4.0.5 on 2022-07-25 13:49 | ||
|
||
import accounts.managers | ||
from django.db import migrations, models | ||
import django.utils.timezone | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('auth', '0012_alter_user_first_name_max_length'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='User', | ||
fields=[ | ||
('id', models.BigAutoField(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(help_text='Provide an email for registration', max_length=320, unique=True, verbose_name='Email')), | ||
('name', models.CharField(max_length=70, verbose_name='Name')), | ||
('date_confirmation_mail_sent', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date confirmation mail sent')), | ||
('date_joined', models.DateTimeField(auto_now_add=True, verbose_name='date joined')), | ||
('is_active', models.BooleanField(default=True, verbose_name='active')), | ||
('is_verified', models.BooleanField(default=False, verbose_name='verified')), | ||
('is_staff', models.BooleanField(default=False, verbose_name='staff')), | ||
('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={ | ||
'verbose_name': 'user', | ||
'verbose_name_plural': 'users', | ||
}, | ||
managers=[ | ||
('objects', accounts.managers.UserManager()), | ||
], | ||
), | ||
] |
17 changes: 17 additions & 0 deletions
17
accounts/migrations/0002_remove_user_date_confirmation_mail_sent.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Generated by Django 4.0.5 on 2022-07-25 14:06 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('accounts', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='user', | ||
name='date_confirmation_mail_sent', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,28 @@ | ||
# from django.utils import timezone | ||
from django.contrib.auth.models import PermissionsMixin | ||
from django.db import models | ||
from django.contrib.auth.base_user import AbstractBaseUser | ||
from .managers import UserManager | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
# Create your models here. | ||
class User(AbstractBaseUser, PermissionsMixin): | ||
email = models.EmailField(_('Email'), unique=True, max_length=320, help_text='Provide an email for registration') | ||
name = models.CharField(_('Name'), max_length=70) | ||
|
||
# date_confirmation_mail_sent = models.DateTimeField(_('date confirmation mail sent'), default=timezone.now) | ||
date_joined = models.DateTimeField(_('date joined'), auto_now_add=True) | ||
is_active = models.BooleanField(_('active'), default=True) | ||
is_verified = models.BooleanField(_('verified'), default=False) | ||
is_staff = models.BooleanField(_('staff'), default=False) | ||
|
||
objects = UserManager() | ||
|
||
USERNAME_FIELD = 'email' | ||
EMAIL_FIELD = 'email' | ||
|
||
class Meta: | ||
verbose_name = _('user') | ||
verbose_name_plural = _('users') | ||
|
||
def __str__(self): | ||
return self.email |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
wcd_mainapp/migrations/0002_remove_tasks_haschanged_tasks_threshold.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 4 additions & 5 deletions
9
...app/migrations/0003_alter_tasks_partof.py → ...ns/0003_tasks_wcd_mainapp_tasks_unique.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
# Generated by Django 4.0.5 on 2022-07-04 16:09 | ||
# Generated by Django 4.0.5 on 2022-07-25 14:17 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('wcd_mainapp', '0002_remove_tasks_haschanged_tasks_threshold'), | ||
('wcd_mainapp', '0002_remove_tasks_haschanged_tasks_threshold_tasks_user_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
migrations.AddConstraint( | ||
model_name='tasks', | ||
name='partOf', | ||
field=models.CharField(default='full', max_length=1000), | ||
constraint=models.UniqueConstraint(fields=('user', 'web_url'), name='wcd_mainapp_tasks_unique'), | ||
), | ||
] |
Oops, something went wrong.