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)