From 0b413322f962776da7be51e5da4f07bbb17e6121 Mon Sep 17 00:00:00 2001 From: sm4640 Date: Thu, 5 Jun 2025 18:22:38 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Feat:=20[#64]=20now=5Fworker=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80,=20thumbnail,=20code=5Fid=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- portfolios/models.py | 9 ++++++--- projects/models.py | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/portfolios/models.py b/portfolios/models.py index f66ec11..d80dc3a 100644 --- a/portfolios/models.py +++ b/portfolios/models.py @@ -2,7 +2,7 @@ from django.db import models from common.models.baseModels import BaseModel -from common.utils.fileManager import dynamic_upload_to +from common.utils.fileManager import DynamicUploadTo from django.contrib.postgres.fields import ArrayField from django.conf import settings @@ -10,6 +10,8 @@ from django.conf import settings from users.models import User +NICKNAME_LEN = 20 + class Portfolio(BaseModel): title = models.CharField(max_length=20) category = ArrayField(models.CharField(max_length=20), default=list) @@ -18,8 +20,9 @@ class Portfolio(BaseModel): like_count = models.IntegerField(default=0) scrap_count = models.IntegerField(default=0) is_represent = models.BooleanField(default=False) - thumbnail = models.ImageField(upload_to=dynamic_upload_to('portfolio', lambda instance: 'thumbnail'), blank=True) - code_id = models.CharField(max_length=26, blank=True) + now_worker = models.CharField(max_length=NICKNAME_LEN, blank=True) + thumbnail = models.ImageField(upload_to=DynamicUploadTo("portfolio", "thumbnail"), null=True, blank=True) + code_id = models.CharField(max_length=26, null=True, blank=True) owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='owned_portfolios', to_field="id") likers = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name='liked_portfolios', blank=True) scrappers = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name='scrapped_portfolios', blank=True) diff --git a/projects/models.py b/projects/models.py index d03f375..246ece8 100644 --- a/projects/models.py +++ b/projects/models.py @@ -3,7 +3,7 @@ from django.db import models from common.models.baseModels import BaseModel from common.models.choiceModels import InvitationStatus -from common.utils.fileManager import dynamic_upload_to +from common.utils.fileManager import DynamicUploadTo from django.contrib.postgres.fields import ArrayField from django.conf import settings @@ -12,6 +12,8 @@ from notifications.models import Notification from users.models import User +NICKNAME_LEN = 20 + class Project(BaseModel): title = models.CharField(max_length=20) is_team = models.BooleanField(default=False) @@ -22,8 +24,9 @@ class Project(BaseModel): like_count = models.IntegerField(default=0) scrap_count = models.IntegerField(default=0) is_represent = models.BooleanField(default=False) - thumbnail = models.ImageField(upload_to=dynamic_upload_to('project', lambda instance: 'thumbnail'), blank=True) - code_id = models.CharField(max_length=26, blank=True) + now_worker = models.CharField(max_length=NICKNAME_LEN, blank=True) + thumbnail = models.ImageField(upload_to=DynamicUploadTo("project", "thumbnail"), null=True, blank=True) + code_id = models.CharField(max_length=26, null=True, blank=True) owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='owned_projects', to_field="id") likers = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name='liked_projects', blank=True) scrappers = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name='scrapped_projects', blank=True)