-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from ryaustin/dir-structure-redo
Dir structure redo
- Loading branch information
Showing
42 changed files
with
380 additions
and
539 deletions.
There are no files selected for viewing
File renamed without changes.
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,50 @@ | ||
from django.contrib import admin | ||
from django.contrib.auth.admin import UserAdmin | ||
|
||
from .forms import CustomUserCreationForm, CustomUserChangeForm | ||
from .models import CustomUser | ||
|
||
|
||
class CustomUserAdmin(UserAdmin): | ||
add_form = CustomUserCreationForm | ||
form = CustomUserChangeForm | ||
model = CustomUser | ||
list_display = ( | ||
"email", | ||
"is_staff", | ||
"is_active", | ||
) | ||
list_filter = ( | ||
"email", | ||
"is_staff", | ||
"is_active", | ||
) | ||
fieldsets = ( | ||
(None, {"fields": ("email", "password")}), | ||
( | ||
"Permissions", | ||
{"fields": ("is_staff", "is_active", "groups", "user_permissions")}, | ||
), | ||
) | ||
add_fieldsets = ( | ||
( | ||
None, | ||
{ | ||
"classes": ("wide",), | ||
"fields": ( | ||
"email", | ||
"password1", | ||
"password2", | ||
"is_staff", | ||
"is_active", | ||
"groups", | ||
"user_permissions", | ||
), | ||
}, | ||
), | ||
) | ||
search_fields = ("email",) | ||
ordering = ("email",) | ||
|
||
|
||
admin.site.register(CustomUser, CustomUserAdmin) |
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,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class CmpConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "cmp" |
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,15 @@ | ||
from django.contrib.auth.forms import UserCreationForm, UserChangeForm | ||
|
||
from .models import CustomUser | ||
|
||
|
||
class CustomUserCreationForm(UserCreationForm): | ||
class Meta: | ||
model = CustomUser | ||
fields = ("email",) | ||
|
||
|
||
class CustomUserChangeForm(UserChangeForm): | ||
class Meta: | ||
model = CustomUser | ||
fields = ("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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Generated by Django 4.2.5 on 2023-09-20 13:51 | ||
|
||
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="CustomUser", | ||
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", | ||
), | ||
), | ||
( | ||
"first_name", | ||
models.CharField( | ||
blank=True, max_length=150, verbose_name="first name" | ||
), | ||
), | ||
( | ||
"last_name", | ||
models.CharField( | ||
blank=True, max_length=150, verbose_name="last name" | ||
), | ||
), | ||
( | ||
"is_staff", | ||
models.BooleanField( | ||
default=False, | ||
help_text="Designates whether the user can log into this admin site.", | ||
verbose_name="staff status", | ||
), | ||
), | ||
( | ||
"is_active", | ||
models.BooleanField( | ||
default=True, | ||
help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.", | ||
verbose_name="active", | ||
), | ||
), | ||
( | ||
"date_joined", | ||
models.DateTimeField( | ||
default=django.utils.timezone.now, verbose_name="date joined" | ||
), | ||
), | ||
( | ||
"email", | ||
models.EmailField( | ||
max_length=254, unique=True, verbose_name="email address" | ||
), | ||
), | ||
( | ||
"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", | ||
"abstract": False, | ||
}, | ||
), | ||
] |
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
|
||
|
||
class UsersManagersTests(TestCase): | ||
|
||
def test_create_user(self): | ||
User = get_user_model() | ||
user = User.objects.create_user(email="[email protected]", password="foo") | ||
|
@@ -26,7 +25,9 @@ def test_create_user(self): | |
|
||
def test_create_superuser(self): | ||
User = get_user_model() | ||
admin_user = User.objects.create_superuser(email="[email protected]", password="foo") | ||
admin_user = User.objects.create_superuser( | ||
email="[email protected]", password="foo" | ||
) | ||
self.assertEqual(admin_user.email, "[email protected]") | ||
self.assertTrue(admin_user.is_active) | ||
self.assertTrue(admin_user.is_staff) | ||
|
@@ -39,4 +40,5 @@ def test_create_superuser(self): | |
pass | ||
with self.assertRaises(ValueError): | ||
User.objects.create_superuser( | ||
email="[email protected]", password="foo", is_superuser=False) | ||
email="[email protected]", password="foo", is_superuser=False | ||
) |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.