Skip to content

Commit dee3078

Browse files
Feat - Adding the created, updated and enabled attributes to custom user
1 parent dbd61cd commit dee3078

File tree

5 files changed

+72
-10
lines changed

5 files changed

+72
-10
lines changed

Diff for: authentication/admin.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ class UserAdmin(BaseUserAdmin):
88
fieldsets = (
99
(None, {"fields": ("username", "password")}),
1010
(_("Personal info"), {"fields": ("first_name", "last_name", "email", "phone")}),
11+
(_("Important dates"), {"fields": ("last_login", "date_joined", "created_at", "updated_at")}),
1112
(_("Permissions"), {"fields": ("is_active", "is_staff", "is_superuser", "groups", "user_permissions")}),
12-
(_("Important dates"), {"fields": ("last_login", "date_joined")}),
13+
(_("Status"), {"fields": ("enabled",)}),
1314
)
1415
add_fieldsets = (
1516
(
@@ -20,8 +21,19 @@ class UserAdmin(BaseUserAdmin):
2021
},
2122
),
2223
)
23-
list_display = ("username", "email", "first_name", "last_name", "is_staff", "phone", "uuid")
24-
search_fields = ("username", "first_name", "last_name", "email", "phone", "uuid")
24+
list_display = (
25+
"username",
26+
"email",
27+
"first_name",
28+
"last_name",
29+
"is_staff",
30+
"phone",
31+
"user_id",
32+
"enabled",
33+
"created_at",
34+
"updated_at",
35+
)
36+
search_fields = ("username", "first_name", "last_name", "email", "phone", "user_id")
2537
ordering = ("username",)
2638

2739

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Generated by Django 5.0.6 on 2024-06-06 04:03
2+
3+
import datetime
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
dependencies = [
9+
("authentication", "0001_initial"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="user",
15+
name="created_at",
16+
field=models.DateTimeField(auto_now_add=True, default=datetime.datetime(2024, 6, 6, 4, 3, 44, 102325)),
17+
preserve_default=False,
18+
),
19+
migrations.AddField(
20+
model_name="user",
21+
name="enabled",
22+
field=models.BooleanField(default=True),
23+
),
24+
migrations.AddField(
25+
model_name="user",
26+
name="updated_at",
27+
field=models.DateTimeField(auto_now=True),
28+
),
29+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Django 5.0.6 on 2024-06-06 04:07
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("authentication", "0002_user_created_at_user_enabled_user_updated_at"),
9+
]
10+
11+
operations = [
12+
migrations.RenameField(
13+
model_name="user",
14+
old_name="uuid",
15+
new_name="user_id",
16+
),
17+
]

Diff for: authentication/models.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44

55

66
class User(AbstractUser):
7-
uuid = models.UUIDField(default=uuid.uuid4, unique=True, editable=False)
7+
user_id = models.UUIDField(default=uuid.uuid4, unique=True, editable=False)
88
phone = models.CharField(max_length=15, blank=True)
9+
created_at = models.DateTimeField(auto_now_add=True)
10+
updated_at = models.DateTimeField(auto_now=True)
11+
enabled = models.BooleanField(default=True)

Diff for: piggywallet/settings/base.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727

2828
AUTH_USER_MODEL = "authentication.User"
2929

30+
# COGNITO SETTINGS
31+
AWS_REGION = os.getenv("AWS_REGION")
32+
COGNITO_USER_POOL_ID = os.getenv("COGNITO_USER_POOL_ID")
33+
COGNITO_APP_CLIENT_ID = os.getenv("COGNITO_APP_CLIENT_ID")
34+
COGNITO_APP_CLIENT_SECRET = os.getenv("COGNITO_APP_CLIENT_SECRET")
35+
3036

3137
# Application definition
3238
INSTALLED_APPS = [
@@ -47,11 +53,6 @@
4753
],
4854
}
4955

50-
# COGNITO SETTINGS
51-
AWS_REGION = os.getenv("AWS_REGION")
52-
COGNITO_USER_POOL_ID = os.getenv("COGNITO_USER_POOL_ID")
53-
COGNITO_APP_CLIENT_ID = os.getenv("COGNITO_APP_CLIENT_ID")
54-
COGNITO_APP_CLIENT_SECRET = os.getenv("COGNITO_APP_CLIENT_SECRET")
5556

5657
MIDDLEWARE = [
5758
"django.middleware.security.SecurityMiddleware",
@@ -115,7 +116,7 @@
115116

116117
USE_I18N = True
117118

118-
USE_TZ = True
119+
USE_TZ = False
119120

120121

121122
# Static files (CSS, JavaScript, Images)

0 commit comments

Comments
 (0)