Skip to content

Commit

Permalink
feat: Add Reformer Special Material Model and SignUp API (#18)
Browse files Browse the repository at this point in the history
* feat: Reformer Add Special Material

* feat: Add Special Material at ReformerSignup

---------

Co-authored-by: SeoJimin <jnuni004@naver.com>
  • Loading branch information
SeoJimin1234 and SeoJimin authored Jan 31, 2024
1 parent de08712 commit c921224
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
4 changes: 4 additions & 0 deletions users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 25 additions & 0 deletions users/migrations/0009_material_user_special_material.py
Original file line number Diff line number Diff line change
@@ -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'),
),
]
5 changes: 5 additions & 0 deletions users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
4 changes: 3 additions & 1 deletion users/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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({
Expand Down

0 comments on commit c921224

Please sign in to comment.