change user_name still used as login and add display_name for dashboard view instead of username on login

This commit is contained in:
Alberto-Audrix committed 2026-09-10 10:51:51 +07:00
1 parent 7a562c18ec
commit 11b0ca26a5
33 files changed
+180 -145

No files matched your search

@@ -7,7 +7,7 @@ from apps.accounts.models import ApiKey, User
def ensure_bootstrap_user(
*,
user_login: str,
user_name: str,
password: str,
status: str,
is_superuser: bool,
@@ -15,9 +15,9 @@ def ensure_bootstrap_user(
stdout,
) -> User:
user, created = User.objects.get_or_create(
user_login=user_login,
user_name=user_name,
defaults={
"user_name": user_login,
"display_name": user_name,
"status": status,
"is_superuser": is_superuser,
},
@@ -25,7 +25,7 @@ def ensure_bootstrap_user(
if not created and user.status != status:
stdout.write(
f"Updating {user_login!r} status {user.status!r} → {status!r}"
f"Updating {user_name!r} status {user.status!r} → {status!r}"
)
should_set_password = created or not user.has_usable_password() or force_password
@@ -35,12 +35,12 @@ def ensure_bootstrap_user(
user.is_superuser = is_superuser
user.save()
action = "Created" if created else "Updated password for"
stdout.write(f"{action} {status} user {user_login}")
stdout.write(f"{action} {status} user {user_name}")
else:
user.status = status
user.is_superuser = is_superuser
user.save(update_fields=["status", "is_superuser", "updated_at"])
stdout.write(f"User {user_login} already exists (password unchanged)")
stdout.write(f"User {user_name} already exists (password unchanged)")
return user
@@ -71,7 +71,7 @@ class Command(BaseCommand):
)
admin = ensure_bootstrap_user(
user_login=admin_user_name,
user_name=admin_user_name,
password=admin_password,
status=User.STATUS_SUPERUSER,
is_superuser=True,
@@ -91,7 +91,7 @@ class Command(BaseCommand):
"BOOTSTRAP_STAFF_PASSWORD is required when BOOTSTRAP_STAFF_USER is set."
)
ensure_bootstrap_user(
user_login=staff_user_name,
user_name=staff_user_name,
password=staff_password,
status=User.STATUS_GM,
is_superuser=False,