diff --git a/users/admin.py b/users/admin.py index 6dee4922..145528c5 100644 --- a/users/admin.py +++ b/users/admin.py @@ -12,4 +12,8 @@ class PortfolioPhoto(admin.ModelAdmin): @admin.register(models.Style) class Style(admin.ModelAdmin): + pass + +@admin.register(models.Material) +class Material(admin.ModelAdmin): pass \ No newline at end of file diff --git a/users/migrations/0009_material_user_special_material.py b/users/migrations/0009_material_user_special_material.py new file mode 100644 index 00000000..2c0f48c9 --- /dev/null +++ b/users/migrations/0009_material_user_special_material.py @@ -0,0 +1,25 @@ +# Generated by Django 4.0 on 2024-01-24 12:29 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0008_remove_user_bios_remove_user_career_and_more'), + ] + + operations = [ + migrations.CreateModel( + name='Material', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=200)), + ], + ), + migrations.AddField( + model_name='user', + name='special_material', + field=models.ManyToManyField(blank=True, related_name='reformers', to='users.Material'), + ), + ] diff --git a/users/models.py b/users/models.py index df878b89..52ddb137 100644 --- a/users/models.py +++ b/users/models.py @@ -87,6 +87,7 @@ class User(AbstractBaseUser, PermissionsMixin): market_name = models.CharField(max_length=50, blank=True, null=True) market_intro = models.TextField(blank=True, null=True) thumbnail_image = models.ImageField(upload_to=get_upload_path, blank=True, null=True) + special_material = models.ManyToManyField("users.Material", related_name = 'reformers', blank=True) #소비자 가입시 필요 필드 prefer_style = models.ManyToManyField("users.Style", related_name = 'styled_consumers', blank=True) @@ -124,4 +125,8 @@ class PortfolioPhoto(TimeStampedModel): #Style 모델 만들기 class Style(models.Model): + name = models.CharField(max_length=200) + +#특수소재 모델 +class Material(models.Model): name = models.CharField(max_length=200) \ No newline at end of file diff --git a/users/services.py b/users/services.py index 1cf5e69d..5d66b672 100644 --- a/users/services.py +++ b/users/services.py @@ -51,7 +51,8 @@ def reformer_sign_up( career_ability : str, career_certification : InMemoryUploadedFile, license_ability : str, - license_certification: InMemoryUploadedFile + license_certification: InMemoryUploadedFile, + special_material : list[str], ): # ext = certificate_studentship.name.split(".")[-1] @@ -84,6 +85,7 @@ def reformer_sign_up( user.save() user.work_style.set(work_style) + user.special_material.set(special_material) #소비자회원가입 def consumer_sign_up( diff --git a/users/views.py b/users/views.py index 8a95dd13..2dbdfbdc 100644 --- a/users/views.py +++ b/users/views.py @@ -35,6 +35,7 @@ class ReformerSignupInputSerializer(serializers.Serializer): career_certification = serializers.FileField(required = False) license_ability =serializers.CharField(required = False) license_certification = serializers.FileField(required = False) + special_material = serializers.ListField(required = False) def post(self, request): serializer = self.ReformerSignupInputSerializer(data = request.data) @@ -60,6 +61,7 @@ def post(self, request): career_certification = data.get('career_certification', None), license_ability =data.get('license_ability', None), license_certification = data.get('license_certification', None), + special_material = data.get('special_material', []), ) return Response({