From 7616226d959f0c2ce5f0d635e7db273494bace87 Mon Sep 17 00:00:00 2001 From: SeoJimin1234 <113419021+SeoJimin1234@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:12:43 +0900 Subject: [PATCH] feat: #9 Fix Required Field for Consumer SIgnup (#13) Co-authored-by: SeoJimin --- ...r_area_alter_user_code_alter_user_phone.py | 28 +++++++++++++++++++ .../0006_alter_user_profile_image.py | 19 +++++++++++++ .../0007_alter_user_profile_image.py | 19 +++++++++++++ users/models.py | 8 +++--- users/views.py | 20 ++++++------- 5 files changed, 80 insertions(+), 14 deletions(-) create mode 100644 users/migrations/0005_alter_user_area_alter_user_code_alter_user_phone.py create mode 100644 users/migrations/0006_alter_user_profile_image.py create mode 100644 users/migrations/0007_alter_user_profile_image.py diff --git a/users/migrations/0005_alter_user_area_alter_user_code_alter_user_phone.py b/users/migrations/0005_alter_user_area_alter_user_code_alter_user_phone.py new file mode 100644 index 0000000..1ceeaa9 --- /dev/null +++ b/users/migrations/0005_alter_user_area_alter_user_code_alter_user_phone.py @@ -0,0 +1,28 @@ +# Generated by Django 4.0 on 2024-01-10 11:27 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0004_alter_user_phone'), + ] + + operations = [ + migrations.AlterField( + model_name='user', + name='area', + field=models.CharField(blank=True, max_length=50, null=True), + ), + migrations.AlterField( + model_name='user', + name='code', + field=models.CharField(blank=True, max_length=5, null=True), + ), + migrations.AlterField( + model_name='user', + name='phone', + field=models.CharField(blank=True, max_length=15, null=True), + ), + ] diff --git a/users/migrations/0006_alter_user_profile_image.py b/users/migrations/0006_alter_user_profile_image.py new file mode 100644 index 0000000..f911363 --- /dev/null +++ b/users/migrations/0006_alter_user_profile_image.py @@ -0,0 +1,19 @@ +# Generated by Django 4.0 on 2024-01-10 11:44 + +from django.db import migrations, models +import users.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0005_alter_user_area_alter_user_code_alter_user_phone'), + ] + + operations = [ + migrations.AlterField( + model_name='user', + name='profile_image', + field=models.ImageField(default='user_profile_image.png', null=True, upload_to=users.models.get_upload_path), + ), + ] diff --git a/users/migrations/0007_alter_user_profile_image.py b/users/migrations/0007_alter_user_profile_image.py new file mode 100644 index 0000000..35f5839 --- /dev/null +++ b/users/migrations/0007_alter_user_profile_image.py @@ -0,0 +1,19 @@ +# Generated by Django 4.0 on 2024-01-10 11:45 + +from django.db import migrations, models +import users.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0006_alter_user_profile_image'), + ] + + operations = [ + migrations.AlterField( + model_name='user', + name='profile_image', + field=models.ImageField(blank=True, default='user_profile_image.png', null=True, upload_to=users.models.get_upload_path), + ), + ] diff --git a/users/models.py b/users/models.py index d9e352f..4fff271 100644 --- a/users/models.py +++ b/users/models.py @@ -69,10 +69,10 @@ class User(AbstractBaseUser, PermissionsMixin): ) email = models.EmailField(max_length=64, unique=True) - phone = models.CharField(max_length = 15, blank=True) - code = models.CharField(max_length=5, blank=True) + phone = models.CharField(max_length = 15, blank=True, null=True) + code = models.CharField(max_length=5, blank=True, null=True) nickname = models.CharField(max_length=20, blank=True) - profile_image = models.ImageField(upload_to=get_upload_path, default = 'user_profile_image.png') + profile_image = models.ImageField(upload_to=get_upload_path, default = 'user_profile_image.png', blank=True, null=True) agreement_terms = models.BooleanField(default = False) follows = models.ManyToManyField("users.User", related_name='followers', blank=True) is_superuser = models.BooleanField(default=False) @@ -88,7 +88,7 @@ class User(AbstractBaseUser, PermissionsMixin): #리폼러 가입시 필요 필드 school = models.CharField(max_length=20, blank=True) is_enrolled = models.CharField(choices=SCHOOL_CHOICES, max_length=20, blank=True) - area = models.CharField(max_length=50, blank=True) + area = models.CharField(max_length=50, blank=True, null=True) career = models.TextField(blank=True) work_style = models.ManyToManyField("users.Style", related_name = 'styled_refomers', blank=True) bios = models.TextField(blank=True) diff --git a/users/views.py b/users/views.py index 9d17cdc..0cbd77a 100644 --- a/users/views.py +++ b/users/views.py @@ -65,11 +65,11 @@ class ConsumerSignUpInputSerializer(serializers.Serializer): email = serializers.EmailField() password = serializers.CharField() nickname = serializers.CharField() - phone = serializers.CharField() - profile_image = serializers.ImageField() - agreement_terms = serializers.CharField() - area = serializers.CharField() - prefer_style = serializers.ListField() + phone = serializers.CharField(required = False) + profile_image = serializers.ImageField(required = False) + agreement_terms = serializers.BooleanField(required = False) + area = serializers.CharField(required = False) + prefer_style = serializers.ListField(required = False) def post(self, request): serializers = self.ConsumerSignUpInputSerializer(data = request.data) @@ -79,12 +79,12 @@ def post(self, request): UserService.consumer_sign_up( email = data.get('email'), password = data.get('password'), - nickname = data.get('nickname'), - phone = data.get('phone'), + nickname = data.get('nickname',), + phone = data.get('phone', None), profile_image = data.get('profile_image'), - agreement_terms= data.get('agreement_terms'), - area = data.get('area'), - prefer_style = data.get('prefer_style'), + agreement_terms= data.get('agreement_terms', False), + area = data.get('area', None), + prefer_style = data.get('prefer_style',[]), ) return Response({