Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: 금융상품 데이터 수집 & 조회 기능 구현 #13

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions back/accounts/fixtures/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,30 +373,6 @@
"commenter": 2
}
},
{
"model": "authtoken.token",
"pk": "1284d1d69b6dadc99d9d3813d7f60da75a7c13c0",
"fields": {
"user": 1,
"created": "2024-11-18T11:12:43.459Z"
}
},
{
"model": "authtoken.token",
"pk": "453ed77eb17802ab6d66a1045463f18a45bc70d4",
"fields": {
"user": 3,
"created": "2024-11-18T11:14:23.713Z"
}
},
{
"model": "authtoken.token",
"pk": "4a07c0d8d6438b32c8dee45c5d46a1000776f465",
"fields": {
"user": 5,
"created": "2024-11-18T11:14:31.191Z"
}
},
{
"model": "authtoken.token",
"pk": "4e32758ae9cbcd1c5a1451dc2bcaad1b69ffb0c9",
Expand Down
25 changes: 13 additions & 12 deletions back/accounts/forms.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from django.contrib.auth import get_user_model
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
# from django.contrib.auth import get_user_model
# from django.contrib.auth.forms import UserCreationForm, UserChangeForm

User = get_user_model()
# 유저 회원가입
class CustomUserCreationForm(UserCreationForm):
class Meta(UserCreationForm.Meta):
model = User
# User = get_user_model()
# # 유저 회원가입
# class CustomUserCreationForm(UserCreationForm):
# class Meta(UserCreationForm.Meta):
# model = User

# 유저 정보수정
class CustomUserChangeForm(UserChangeForm):
class Meta(UserChangeForm.Meta):
model = User
fields = ('first_name', 'last_name', 'email',)

# # 유저 정보수정
# class CustomUserChangeForm(UserChangeForm):
# class Meta(UserChangeForm.Meta):
# model = User
# fields = ('first_name', 'last_name', 'email',)
66 changes: 32 additions & 34 deletions back/accounts/managers.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
from django.contrib.auth.models import BaseUserManager
# from django.contrib.auth.models import BaseUserManager

# 유저생성 커스텀
class UserManager(BaseUserManager):
def create_user(self, username, password, fullname, nickname=None, email=None, profile_image='profile_images/default.png', **extra_fields):
"""
일반 유저 생성
"""
if not username:
raise ValueError("The Username must be set")
if not password:
raise ValueError("The Password must be set")
if not fullname:
raise ValueError("The Fullname must be set")
# 이메일 정규화
email = self.normalize_email(email) if email else None
# 유저 생성
user = self.model(username=username, password=password, fullname=fullname, nickname=nickname, email=email, profile_image=profile_image, **extra_fields)
user.set_password(password)
user.save(using=self._db)
return user
# # 유저생성 커스텀
# class UserManager(BaseUserManager):
# def create_user(self, username, password, nickname=None, email=None, profile_image='profile_images/default.png', **extra_fields):
# """
# 일반 유저 생성
# """
# if not username:
# raise ValueError("The Username must be set")
# if not password:
# raise ValueError("The Password must be set")
# # 이메일 정규화
# email = self.normalize_email(email) if email else None
# # 유저 생성
# user = self.model(username=username, password=password, nickname=nickname, email=email, profile_image=profile_image, **extra_fields)
# user.set_password(password)
# user.save(using=self._db)
# return user

def create_superuser(self, username, email=None, password=None, **extra_fields):
"""
슈퍼 유저 생성
"""
extra_fields.setdefault('is_staff', True)
extra_fields.setdefault('is_superuser', True)
# 필요한 필드에 기본값 추가
extra_fields.setdefault('nickname', 'Admin')
extra_fields.setdefault('fullname', 'superuser')
# def create_superuser(self, username, email=None, password=None, **extra_fields):
# """
# 슈퍼 유저 생성
# """
# extra_fields.setdefault('is_staff', True)
# extra_fields.setdefault('is_superuser', True)
# # 필요한 필드에 기본값 추가
# extra_fields.setdefault('nickname', 'Admin')
# extra_fields.setdefault('fullname', 'superuser')

if extra_fields.get('is_staff') is not True:
raise ValueError('Superuser must have is_staff=True.')
if extra_fields.get('is_superuser') is not True:
raise ValueError('Superuser must have is_superuser=True.')
# if extra_fields.get('is_staff') is not True:
# raise ValueError('Superuser must have is_staff=True.')
# if extra_fields.get('is_superuser') is not True:
# raise ValueError('Superuser must have is_superuser=True.')

return self.create_user(username, email, password, **extra_fields)
# return self.create_user(username, email, password, **extra_fields)
6 changes: 3 additions & 3 deletions back/accounts/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.16 on 2024-11-18 01:50
# Generated by Django 4.2.16 on 2024-11-19 00:43

from django.db import migrations, models

Expand All @@ -22,14 +22,14 @@ class Migration(migrations.Migration):
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
('nickname', models.CharField(max_length=150, unique=True)),
('nickname', models.CharField(max_length=10)),
('fullname', models.CharField(max_length=50)),
('profile_image', models.ImageField(default='profile_images/default.png', upload_to='profile_images/')),
('date_joined', models.DateField(auto_now_add=True)),
('deleted_at', models.DateTimeField(blank=True, null=True)),
('username', models.CharField(max_length=255, unique=True)),
('password', models.CharField(max_length=255)),
('email', models.EmailField(blank=True, default=None, max_length=254, null=True, unique=True)),
('email', models.EmailField(blank=True, default=None, max_length=254, null=True)),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')),
],
Expand Down
18 changes: 0 additions & 18 deletions back/accounts/migrations/0002_alter_user_email.py

This file was deleted.

20 changes: 20 additions & 0 deletions back/accounts/migrations/0002_alter_user_managers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.16 on 2024-11-19 05:18

import django.contrib.auth.models
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('accounts', '0001_initial'),
]

operations = [
migrations.AlterModelManagers(
name='user',
managers=[
('objects', django.contrib.auth.models.UserManager()),
],
),
]
18 changes: 0 additions & 18 deletions back/accounts/migrations/0003_alter_user_nickname.py

This file was deleted.

19 changes: 19 additions & 0 deletions back/accounts/migrations/0003_user_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.2.16 on 2024-11-19 06:03

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('accounts', '0002_alter_user_managers'),
]

operations = [
migrations.AddField(
model_name='user',
name='test',
field=models.CharField(default=1, max_length=50),
preserve_default=False,
),
]
18 changes: 0 additions & 18 deletions back/accounts/migrations/0004_alter_user_nickname.py

This file was deleted.

17 changes: 17 additions & 0 deletions back/accounts/migrations/0004_remove_user_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.16 on 2024-11-19 06:08

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('accounts', '0003_user_test'),
]

operations = [
migrations.RemoveField(
model_name='user',
name='test',
),
]
18 changes: 0 additions & 18 deletions back/accounts/migrations/0005_alter_user_nickname.py

This file was deleted.

5 changes: 2 additions & 3 deletions back/accounts/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.db import models
from django.contrib.auth.models import AbstractUser
from allauth.account.adapter import DefaultAccountAdapter
from .managers import UserManager
# from .managers import UserManager

# 유저
class User(AbstractUser):
Expand All @@ -11,7 +11,6 @@ class User(AbstractUser):
profile_image = models.ImageField(upload_to="profile_images/", default='profile_images/default.png') # 프로필 이미지
date_joined = models.DateField(auto_now_add=True) # 가입일자
deleted_at = models.DateTimeField(null=True, blank=True) # 탈퇴 일자

# 일반회원
username = models.CharField(max_length=255, unique=True) # 로그인ID
password = models.CharField(max_length=255) # 비밀번호
Expand All @@ -20,7 +19,7 @@ class User(AbstractUser):
email = models.EmailField(null=True, blank=True, default=None) # 이메일

# 커스텀 매니저 연결
objects = UserManager()
# objects = UserManager()

def __str__(self):
return self.nickname if self.nickname else f"User({self.username})" # 닉네임이 없으면 로그인 ID 반환
Expand Down
8 changes: 6 additions & 2 deletions back/algofipo_pjt/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
import environ
env = environ.Env(DEBUG=(bool, True)) # 환경변수 저장 가능한 상태로 설정
environ.Env.read_env(env_file=os.path.join(BASE_DIR, '.env')) # 환경변수 읽어올 파일
KAKAO_LOGIN_API_KEY = env('KAKAO_LOGIN_API_KEY')
DJANGO_SECRET_KEY = env('DJANGO_SECRET_KEY')

KAKAO_LOGIN_API_KEY = env("KAKAO_LOGIN_API_KEY") # 카카오로그인
DJANGO_SECRET_KEY = env("DJANGO_SECRET_KEY")
FSS_API_KEY = env("FSS_API_KEY") # 금융감독원

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/

Expand All @@ -40,6 +43,7 @@
# my app
"accounts",
"articles",
"products",

# third party
"corsheaders", # CORS header
Expand Down
15 changes: 9 additions & 6 deletions back/algofipo_pjt/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@
from django.conf.urls.static import static

urlpatterns = [
path('admin/', admin.site.urls),

# Articles API
path('api/v1/', include('articles.urls')),
path("admin/", admin.site.urls),

# Authentication
path('accounts/', include('accounts.urls')), # 소셜 로그인, 회원가입, 회원탈퇴
path("accounts/", include("accounts.urls")), # 소셜 로그인, 회원가입, 회원탈퇴
path("accounts/", include("dj_rest_auth.urls")), # 로그인, 로그아웃, 비밀번호 변경 등
# path('api-auth/', include('rest_framework.urls')), # DRF 기본 인증뷰 (세션인증)
# path("api-auth/", include("rest_framework.urls")), # DRF 기본 인증뷰 (세션인증)

# Articles API
path("api/v1/", include("articles.urls")),

# Products API
path("api/v1/products/", include("products.urls")),
]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
2 changes: 1 addition & 1 deletion back/articles/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.16 on 2024-11-18 01:50
# Generated by Django 4.2.16 on 2024-11-19 01:37

from django.conf import settings
from django.db import migrations, models
Expand Down
Empty file added back/products/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions back/products/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions back/products/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class ProductsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'products'
Loading