From 3b52eb1813dc6eb5a5078543bdc645fca4e04517 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Fri, 7 Mar 2025 09:37:28 +0800 Subject: [PATCH] fix --- account/api.py | 6 +++--- account/migrations/0001_initial.py | 4 +--- account/models.py | 3 +++ submission/migrations/0001_initial.py | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/account/api.py b/account/api.py index c805381..080f0aa 100644 --- a/account/api.py +++ b/account/api.py @@ -12,7 +12,7 @@ from .schemas import ( UserRegistrationSchema, UserLoginSchema, ) -from .models import Profile, RoleChoices, User +from .models import Profile, RoleChoices, User, create_user_profile from .decorators import super_required router = Router() @@ -91,9 +91,9 @@ def batch_create(request, payload: BatchUsersIn): for user in user_list: profile_list.append(Profile(user=user)) - post_save.disconnect(sender=User, dispatch_uid="1") + post_save.disconnect(create_user_profile, sender=User) User.objects.bulk_create(user_list) - post_save.connect(sender=User, dispatch_uid="1") + post_save.connect(create_user_profile, sender=User) Profile.objects.bulk_create(profile_list) return {"message": "批量创建成功"} diff --git a/account/migrations/0001_initial.py b/account/migrations/0001_initial.py index 84c3c77..d480a86 100644 --- a/account/migrations/0001_initial.py +++ b/account/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.6 on 2025-03-06 16:03 +# Generated by Django 5.1.6 on 2025-03-07 01:32 import django.contrib.auth.models import django.contrib.auth.validators @@ -25,8 +25,6 @@ class Migration(migrations.Migration): ('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')), diff --git a/account/models.py b/account/models.py index 48d5bc2..1595b58 100644 --- a/account/models.py +++ b/account/models.py @@ -12,6 +12,9 @@ class RoleChoices(models.TextChoices): class User(AbstractUser): + first_name = None + last_name = None + role = models.CharField( max_length=20, choices=RoleChoices.choices, diff --git a/submission/migrations/0001_initial.py b/submission/migrations/0001_initial.py index f7fff1f..8e1650a 100644 --- a/submission/migrations/0001_initial.py +++ b/submission/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.6 on 2025-03-06 16:03 +# Generated by Django 5.1.6 on 2025-03-07 01:32 import django.db.models.deletion import django_extensions.db.fields