Skip to content

Commit

Permalink
Add custom user model
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysyngsun committed Feb 27, 2025
1 parent 8bdc03e commit 4521b94
Show file tree
Hide file tree
Showing 10 changed files with 203 additions and 55 deletions.
110 changes: 55 additions & 55 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@
"line_number": 20
}
],
"conftest.py": [
{
"type": "Secret Keyword",
"filename": "conftest.py",
"hashed_secret": "e5e9fa1ba31ecd1ae84f75caaa474f3a663f05f4",
"is_verified": false,
"line_number": 123
}
],
"docker-compose.yml": [
{
"type": "Secret Keyword",
Expand Down Expand Up @@ -205,13 +214,54 @@
"line_number": 19
}
],
"conftest.py": [
"testapp/main/settings/dev.py": [
{
"type": "Secret Keyword",
"filename": "conftest.py",
"hashed_secret": "e5e9fa1ba31ecd1ae84f75caaa474f3a663f05f4",
"filename": "testapp/main/settings/dev.py",
"hashed_secret": "6367c48dd193d56ea7b0baad25b19455e529f5ee",
"is_verified": false,
"line_number": 123
"line_number": 17
}
],
"testapp/main/settings/example.dev.py": [
{
"type": "Secret Keyword",
"filename": "testapp/main/settings/example.dev.py",
"hashed_secret": "6367c48dd193d56ea7b0baad25b19455e529f5ee",
"is_verified": false,
"line_number": 14
}
],
"testapp/main/settings/shared.py": [
{
"type": "Secret Keyword",
"filename": "testapp/main/settings/shared.py",
"hashed_secret": "8f2581750096043a1c68bedea8cfa6e13ad1a2e4",
"is_verified": false,
"line_number": 40
},
{
"type": "Basic Auth Credentials",
"filename": "testapp/main/settings/shared.py",
"hashed_secret": "afc848c316af1a89d49826c5ae9d00ed769415f3",
"is_verified": false,
"line_number": 122
},
{
"type": "Secret Keyword",
"filename": "testapp/main/settings/shared.py",
"hashed_secret": "9bc34549d565d9505b287de0cd20ac77be1d3f2c",
"is_verified": false,
"line_number": 202
}
],
"testapp/main/settings/test.py": [
{
"type": "Secret Keyword",
"filename": "testapp/main/settings/test.py",
"hashed_secret": "6367c48dd193d56ea7b0baad25b19455e529f5ee",
"is_verified": false,
"line_number": 9
}
],
"tests/common/utils/test_urls.py": [
Expand Down Expand Up @@ -267,57 +317,7 @@
"is_verified": false,
"line_number": 29
}
],
"testapp/main/settings/dev.py": [
{
"type": "Secret Keyword",
"filename": "testapp/main/settings/dev.py",
"hashed_secret": "6367c48dd193d56ea7b0baad25b19455e529f5ee",
"is_verified": false,
"line_number": 17
}
],
"testapp/main/settings/example.dev.py": [
{
"type": "Secret Keyword",
"filename": "testapp/main/settings/example.dev.py",
"hashed_secret": "6367c48dd193d56ea7b0baad25b19455e529f5ee",
"is_verified": false,
"line_number": 14
}
],
"testapp/main/settings/shared.py": [
{
"type": "Secret Keyword",
"filename": "testapp/main/settings/shared.py",
"hashed_secret": "8f2581750096043a1c68bedea8cfa6e13ad1a2e4",
"is_verified": false,
"line_number": 40
},
{
"type": "Basic Auth Credentials",
"filename": "testapp/main/settings/shared.py",
"hashed_secret": "afc848c316af1a89d49826c5ae9d00ed769415f3",
"is_verified": false,
"line_number": 120
},
{
"type": "Secret Keyword",
"filename": "testapp/main/settings/shared.py",
"hashed_secret": "9bc34549d565d9505b287de0cd20ac77be1d3f2c",
"is_verified": false,
"line_number": 200
}
],
"testapp/main/settings/test.py": [
{
"type": "Secret Keyword",
"filename": "testapp/main/settings/test.py",
"hashed_secret": "6367c48dd193d56ea7b0baad25b19455e529f5ee",
"is_verified": false,
"line_number": 9
}
]
},
"generated_at": "2025-02-26T21:06:50Z"
"generated_at": "2025-02-27T14:23:42Z"
}
2 changes: 2 additions & 0 deletions testapp/main/settings/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

ALLOWED_HOSTS = ["*"]

AUTH_USER_MODEL = "users.User"

# Application definition

Expand Down Expand Up @@ -74,6 +75,7 @@
"mitol.transcoding.apps.Transcoding",
# test app, integrates the reusable apps
"main",
"users",
]

MIDDLEWARE = [
Expand Down
Empty file added testapp/users/__init__.py
Empty file.
1 change: 1 addition & 0 deletions testapp/users/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Register your models here.
6 changes: 6 additions & 0 deletions testapp/users/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class UsersConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "users"
131 changes: 131 additions & 0 deletions testapp/users/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Generated by Django 4.2.16 on 2025-02-27 14:21

import django.contrib.auth.models
import django.contrib.auth.validators
import django.utils.timezone
from django.db import migrations, models


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",
),
),
(
"username",
models.CharField(
error_messages={
"unique": "A user with that username already exists."
},
help_text="Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.",
max_length=150,
unique=True,
validators=[
django.contrib.auth.validators.UnicodeUsernameValidator()
],
verbose_name="username",
),
),
(
"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"
),
),
(
"email",
models.EmailField(
blank=True, max_length=254, verbose_name="email address"
),
),
(
"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"
),
),
(
"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,
},
managers=[
("objects", django.contrib.auth.models.UserManager()),
],
),
]
Empty file.
6 changes: 6 additions & 0 deletions testapp/users/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.contrib.auth.models import AbstractUser


# Create your models here.
class User(AbstractUser):
"""Custom user"""
1 change: 1 addition & 0 deletions testapp/users/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Create your tests here.
1 change: 1 addition & 0 deletions testapp/users/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Create your views here.

0 comments on commit 4521b94

Please sign in to comment.