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

10월14일11:09 #187

Merged
merged 27 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
adcbb45
refactor: 모델 수정
devnproyj22 Oct 13, 2024
e0084f8
refactor: 시리얼라이저 수정
devnproyj22 Oct 13, 2024
9bd69a1
refactor: 뷰 수정
devnproyj22 Oct 13, 2024
2d66e1d
refactor: 뷰 수정
devnproyj22 Oct 13, 2024
3f6db4a
refactor: 뷰 수정
devnproyj22 Oct 13, 2024
87c5c17
refactor: 뷰 수정
devnproyj22 Oct 13, 2024
08d2cee
refactor: materials/models.py 수정 - is_deleted 추가
devnproyj22 Oct 14, 2024
a9139dc
refactor: materials/urls.py 수정 - id 추가
devnproyj22 Oct 14, 2024
c1f487d
refactor: materials/serializers.py 수정 - 시리얼라이저 삭제
devnproyj22 Oct 14, 2024
515641e
refactor: materials/views.py 수정 - 뷰 추가
devnproyj22 Oct 14, 2024
368de38
refactor: materials/views.py 수정 - 뷰 추가
devnproyj22 Oct 14, 2024
9a2264a
refactor: materials/urls.py 수정 - id 추가
devnproyj22 Oct 14, 2024
d43156f
refactor: materials/models.py 수정 - is_deleted 추가
devnproyj22 Oct 14, 2024
144ecaf
refactor: materials/migrations 추가
devnproyj22 Oct 14, 2024
b971da9
Merge pull request #178 from weaverse-techtide/yujeong/materials
AlbertImKr Oct 14, 2024
828b699
refactor: 결제 리텍토링
AlbertImKr Oct 14, 2024
b93b412
Refactor: 소셜로그인 설정 수정
nathanLYJ Oct 14, 2024
da58b81
feat: 구글 사이트 통해서 로그인, 사용자 정보 처리, 회원가입 처리
nathanLYJ Oct 14, 2024
2d77ee1
feat: 구글 로그인 주석 추가
nathanLYJ Oct 14, 2024
ba01984
refactor: readme 로고추가, 팀구성, 기술스택, API 엔더포인트 수정
nathanLYJ Oct 14, 2024
9018fa2
refactor: 로고 크기 수정
nathanLYJ Oct 14, 2024
9b7480d
fix: Readme 복구
nathanLYJ Oct 14, 2024
d0eae85
Merge pull request #180 from weaverse-techtide/nathan/social_login3
AlbertImKr Oct 14, 2024
49b5600
fix: 코드 수정
AlbertImKr Oct 14, 2024
2e99b0a
이미지 파일 업로드
nathanLYJ Oct 14, 2024
ff8c161
Merge branch 'dev' into 182-payment-refactoring
AlbertImKr Oct 14, 2024
6ca9c24
Merge pull request #186 from weaverse-techtide/182-payment-refactoring
AlbertImKr Oct 14, 2024
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,4 @@ python manage.py runserver

### 최종 검토 및 문서화

![week3](assets/images/week3.png)
![week3](assets/images/week3.png)
4 changes: 2 additions & 2 deletions accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ def __str__(self):
return self.email

def get_image_url(self):
if getattr(self, "image", None):
return self.image.image_url
if hasattr(self, "image") and hasattr(self.image, "url"):
return self.image.url
return "https://paullab.co.kr/images/weniv-licat.png"
Binary file added assets/images/유연우.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/유원길.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/이유정.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/임홍광.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions courses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ class Course(models.Model):
updated_at = models.DateTimeField(auto_now=True, verbose_name="수정일")

def get_thumbnail(self):
if hasattr(self, "images") and self.images.exists():
return self.images.first().file.url
if hasattr(self, "image"):
return self.image.url
return "https://www.gravatar.com/avatar/205e460b479e2e5b48aec077"

def update(self, **kwargs):
Expand Down
11 changes: 7 additions & 4 deletions courses/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Meta:

def get_video_url(self, obj):
if getattr(obj, "video", None):
return obj.video.video_url
return obj.video.url
return None

def get_video_duration(self, obj):
Expand Down Expand Up @@ -164,17 +164,16 @@ class Meta:
]

def get_author_image(self, obj):
print(obj.author.image.image_url)
if getattr(obj.author, "image", None):
return obj.author.image.image_url
return obj.author.image.url
return None

def get_author_name(self, obj):
return obj.author.nickname

def get_video_url(self, obj):
if getattr(obj, "video", None):
return obj.video.video_url
return obj.video.url
return None

def get_thumbnail_url(self, obj):
Expand Down Expand Up @@ -233,6 +232,8 @@ def get_thumbnail(self, obj):
return obj.get_thumbnail()

def get_author_image(self, obj):
if getattr(obj.author, "image", None):
return obj.author.image.url
return "https://paullab.co.kr/images/weniv-licat.png"

def get_author_name(self, obj):
Expand Down Expand Up @@ -314,6 +315,8 @@ class Meta:
]

def get_author_image(self, obj):
if getattr(obj.author, "image", None):
return obj.author.image.url
return "https://paullab.co.kr/images/weniv-licat.png"

def get_author_name(self, obj):
Expand Down
4 changes: 2 additions & 2 deletions courses/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def create_user():
user = User.objects.create_user(
email=TEST_USER_EMAIL, password=TEST_USER_PASSWORD, nickname="testuser"
)
Image.objects.create(user=user, image_url="test.jpg")
Image.objects.create(user=user, url="test.jpg")
return user


Expand All @@ -148,7 +148,7 @@ def create_staff_user():
is_staff=True,
nickname="staffuser",
)
Image.objects.create(user=user, image_url="test.jpg")
Image.objects.create(user=user, url="test.jpg")
return user


Expand Down
41 changes: 37 additions & 4 deletions jwtauth/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging

import jwt
from allauth.socialaccount.providers.google.views import GoogleOAuth2Adapter
from allauth.socialaccount.providers.oauth2.client import OAuth2Client
Expand Down Expand Up @@ -166,23 +165,57 @@ def post(self, request):


class GoogleLogin(SocialLoginView):
"""
사용자가 구글 로그인을 할 때 사용, 구글 로그인을 위한 소셜 로그인 뷰입니다.
사용자가 구글사이트에서 로그인을 완료하면, 사용자 정보를 받아서 회원가입 또는 로그인 처리합니다.
닉네임은 이메일 주소의 @ 앞부분을 사용하고, 비밀번호는 사용하지 않습니다.
쿠기에 리프레시 토큰과 액세스 토큰을 저장합니다.
"""

adapter_class = GoogleOAuth2Adapter
callback_url = settings.GOOGLE_CALLBACK_URL
client_class = OAuth2Client

def get(self, request, *args, **kwargs):
"""
GET 요청: 구글 로그인 페이지로 리다이렉트
"""
return super().get(request, *args, **kwargs)

def get_response(self):
"""
소셜 로그인 완료 후 사용자 정보 처리
"""
response = super().get_response()

user = self.user

if not User.objects.filter(email=user.email).exists():
user = User.objects.create_user(
nickname=user.mail.split("@")[0],
email=user.email,
)
user.set_unusable_password()
user.save()

access_token = generate_access_token(user)
refresh_token = generate_refresh_token(user)

response = redirect(settings.LOGIN_REDIRECT_URL)
same_site = None if settings.DEBUG else "Lax"
response.set_cookie(
key="refresh_token",
value=refresh_token,
httponly=True,
secure=not settings.DEBUG,
samesite="None",
samesite=same_site,
max_age=60 * 60 * 24 * 14,
)
response.set_cookie(
key="access_token",
value=access_token,
secure=not settings.DEBUG,
samesite=same_site,
max_age=60 * 30,
)
response.data = {"access_token": access_token}

return response
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Generated by Django 5.1.1 on 2024-10-14 05:25

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('materials', '0007_alter_image_author'),
]

operations = [
migrations.AlterModelOptions(
name='image',
options={'ordering': ['-created_at']},
),
migrations.AlterModelOptions(
name='video',
options={'ordering': ['-created_at']},
),
migrations.AlterModelOptions(
name='videoeventdata',
options={'ordering': ['-timestamp']},
),
migrations.AddField(
model_name='image',
name='is_deleted',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='video',
name='is_deleted',
field=models.BooleanField(default=False),
),
migrations.AlterField(
model_name='image',
name='image_url',
field=models.ImageField(blank=True, null=True, upload_to='images/', verbose_name='이미지 파일'),
),
migrations.AlterField(
model_name='video',
name='video_url',
field=models.FileField(blank=True, null=True, upload_to='videos/', verbose_name='비디오 파일'),
),
migrations.AlterField(
model_name='videoeventdata',
name='duration',
field=models.FloatField(verbose_name='동영상 전체 길이'),
),
migrations.AlterField(
model_name='videoeventdata',
name='video',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='video_event_datas', to='materials.video', verbose_name='시청 기록의 해당 동영상'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 5.1.1 on 2024-10-14 06:31

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('materials', '0008_alter_image_options_alter_video_options_and_more'),
]

operations = [
migrations.RemoveField(
model_name='image',
name='image_url',
),
migrations.RemoveField(
model_name='video',
name='video_url',
),
]
23 changes: 23 additions & 0 deletions materials/migrations/0010_image_url_video_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.1.1 on 2024-10-14 06:34

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('materials', '0009_remove_image_image_url_remove_video_video_url'),
]

operations = [
migrations.AddField(
model_name='image',
name='url',
field=models.URLField(default='https://paullab.co.kr/images/weniv-licat.png', verbose_name='이미지 URL'),
),
migrations.AddField(
model_name='video',
name='url',
field=models.URLField(default='https://www.youtube.com/watch?v=bZh8oUIDfdI&t=1s', verbose_name='동영상 URL'),
),
]
Loading
Loading