-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔀 Merge branch 'main' into feat/symbol-selection
- Loading branch information
Showing
26 changed files
with
864 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from storages.backends.s3boto3 import S3Boto3Storage | ||
|
||
|
||
# settings.py에서 static과 media에 storages.backends.s3boto3.S3Boto3Storage를 사용할 수 있지만 | ||
# 그러면 둘이 같은 경로에서 관리되므로 여기서 분리해줌 (저장 경로 관련된 부분) | ||
# 우리 앱은 static 쓸 일 크게 없을 것 같긴 하지만.. | ||
class MediaStorage(S3Boto3Storage): | ||
location = 'media' | ||
file_overwrite = False | ||
|
||
|
||
class StaticStorage(S3Boto3Storage): | ||
location = 'static' | ||
file_overwrite = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 3.2.6 on 2023-10-27 04:01 | ||
|
||
from django.db import migrations, models | ||
import entry.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('entry', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='symbol', | ||
name='image', | ||
field=models.ImageField(blank=True, upload_to=entry.models.img_upload_func), | ||
), | ||
migrations.AddField( | ||
model_name='symbol', | ||
name='is_valid', | ||
field=models.BooleanField(default=False), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Generated by Django 3.2.6 on 2023-10-28 08:42 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('entry', '0002_auto_20231027_1301'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='symbol', | ||
name='category', | ||
field=models.IntegerField(), | ||
), | ||
migrations.DeleteModel( | ||
name='Category', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.2.6 on 2023-10-28 11:07 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('entry', '0003_auto_20231028_1742'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='symbol', | ||
name='text', | ||
field=models.CharField(max_length=20), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Generated by Django 3.2.6 on 2023-10-29 04:35 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('entry', '0004_alter_symbol_text'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='symbol', | ||
name='created_by', | ||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='symbols', to=settings.AUTH_USER_MODEL), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Generated by Django 3.2.6 on 2023-10-29 05:51 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('entry', '0005_alter_symbol_created_by'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='symbol', | ||
name='created_by', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='symbols', to=settings.AUTH_USER_MODEL), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,33 @@ | ||
import os | ||
from django.utils import timezone | ||
from uuid import uuid4 | ||
|
||
from django.db import models | ||
|
||
from user.models import User | ||
|
||
|
||
# Create your models here. | ||
# 저장 경로 설정 | ||
def img_upload_func(instance, filename): | ||
prefix = 'symbol/user_{}/'.format(instance.created_by.id) | ||
ymd_path = timezone.now().strftime('%Y%m%d') | ||
file_name = uuid4().hex # random string | ||
extension = os.path.splitext(filename)[-1].lower() # 확장자 추출 | ||
return "".join( | ||
[prefix, ymd_path, file_name, extension, ] | ||
) | ||
|
||
|
||
class Symbol(models.Model): | ||
text = models.CharField(max_length=15, null=False, blank=False) | ||
category = models.ForeignKey('Category', related_name='symbols', on_delete=models.CASCADE) # Would it be better to use SET_NULL/DEFAULT? | ||
# image = models.ImageField | ||
created_by = models.ForeignKey('user.User', related_name='symbols', on_delete=models.CASCADE) | ||
text = models.CharField(max_length=20, null=False, blank=False) | ||
category = models.IntegerField(null=False, blank=False) | ||
image = models.ImageField(blank=True, upload_to=img_upload_func) | ||
created_by = models.ForeignKey('user.User', related_name='symbols', on_delete=models.CASCADE, null=True, blank=True) | ||
created_at = models.DateTimeField(auto_now_add=True) | ||
is_valid = models.BooleanField(default=False) | ||
|
||
|
||
class FavoriteSymbol(models.Model): | ||
symbol = models.ForeignKey('Symbol', related_name='favorites', on_delete=models.CASCADE) | ||
user = models.ForeignKey('user.User', related_name='favorites', on_delete=models.CASCADE) | ||
created_at = models.DateTimeField(auto_now_add=True) | ||
|
||
|
||
# Would it be better to remove this category table? | ||
# doesn't seem so useful.. | ||
class Category(models.Model): | ||
text = models.CharField(max_length=15, null=False, blank=False) | ||
created_at = models.DateTimeField(auto_now_add=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.