Skip to content
Open
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
Binary file removed likelion_inha_team5/likelion_inha_team5/db.sqlite3
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]



AUTH_USER_MODEL = 'workhol.MyUser' #추가 21:10

# 오류뜨는 것 같아 주석처리
CORS_ALLOW_ALL_ORIGINS = True # all 추가
# CORS_ALLOW_ALL_ORIGINS = True # all 추가


# CORS_ALLOWED_ORIGINS = [
Expand All @@ -54,6 +58,7 @@
# CORS_ALLOW_CREDENTIALS = True # 자격 증명 허용

CORS_ALLOW_HEADERS = ['*']

# CORS_ALLOW_HEADERS = [
# 'accept',
# 'accept-encoding',
Expand All @@ -67,6 +72,7 @@
# ]



CORS_ALLOW_METHODS = [
'DELETE',
'GET',
Expand All @@ -76,7 +82,10 @@
'PUT',
]


# CSRF_TRUSTED_ORIGINS = [
# "http://localhost:3000",
# "http://43.200.226.225",
# ]

ROOT_URLCONF = "likelion_inha_team5.urls"

Expand Down
1 change: 1 addition & 0 deletions likelion_inha_team5/likelion_inha_team5/workhol/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
path('intern/', views.intern_site, name='intern_site'),
path('<str:site_name>/<str:category_name>/post/', views.create_post, name='create_post'),
path('<str:site_name>/<str:category_name>/', views.post_list, name='post_list'),
path('<str:category_name>/', views.category_list, name='category_list'),
path('<str:site_name>/<str:category_name>/<int:id>', views.post_detail, name='post_detail'),
path('<str:site_name>/<str:category_name>/<int:id>/update/', views.post_update, name='post_update'),
path('<str:site_name>/<str:category_name>/<int:id>/delete/', views.post_delete, name='post_delete'),
Expand Down
22 changes: 21 additions & 1 deletion likelion_inha_team5/likelion_inha_team5/workhol/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,27 @@ def post_list(request, site_name, category_name):
site = get_object_or_404(Site, site_name=site_name)
category = get_object_or_404(Category, category_name=category_name)
posts = Post.objects.filter(site=site, category=category)
return render(request, 'workhol/post_list.html', {'posts': posts, 'site_name': site_name, 'category_name': category_name})
return Response({'posts': list(posts.values()), 'site_name': site_name, 'category_name': category_name}, status=200)
#return render(request, 'workhol/post_list.html', {'posts': posts, 'site_name': site_name, 'category_name': category_name})

# 각 카테고리 별 게시물 목록
@swagger_auto_schema(
method="get",
tags=["카테고리별 게시물"],
operation_summary="카테고리별 게시물 목록",
operation_description="카테고리별게시물 목록을 가져옵니다.",
responses={
200: '카테고리별 게시물 목록 가져오기 성공',
500: '서버 오류'
}
)
@api_view(['GET'])
def category_list(request, category_name):
category = get_object_or_404(Category, category_name=category_name)
posts = Post.objects.filter(category=category)
return Response({'posts': list(posts.values()), 'category_name': category_name}, status=200)



# 게시물 상세보기
@swagger_auto_schema(
Expand Down