From 9003b231aa77059befba97773760fc1617eb83e0 Mon Sep 17 00:00:00 2001 From: CPABONG Date: Sun, 3 Aug 2025 13:52:41 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=80=EC=83=89=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B6=8C=ED=95=9C=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95:?= =?UTF-8?q?=20=EC=8A=88=ED=8D=BC=EC=9C=A0=EC=A0=80=EB=8F=84=20=EC=A0=84?= =?UTF-8?q?=EC=B2=B4=20DB=20=EA=B2=80=EC=83=89=20=EA=B0=80=EB=8A=A5?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- A_core/urls.py | 8 ++++---- B_main/urls.py | 7 +------ B_main/views.py | 13 ++++++++++--- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/A_core/urls.py b/A_core/urls.py index ce2d708..451c4c1 100644 --- a/A_core/urls.py +++ b/A_core/urls.py @@ -15,10 +15,11 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path, include +from django.urls import path, include, re_path from django.views.generic import RedirectView from django.conf import settings from django.conf.urls.static import static +from django.views.static import serve urlpatterns = [ @@ -28,11 +29,10 @@ urlpatterns = [ path('accounts/', include('allauth.urls')), # allauth 기본 URL path('accounts/', include('C_accounts.urls')), # 커스텀 계정 URL path('', include('B_main.urls')), + # 미디어 파일 서빙 (DEBUG=False 상황에서도 작동) + re_path(r'^media/(?P.*)$', serve, {'document_root': settings.MEDIA_ROOT}), ] -# 미디어 파일 서빙 (개발 및 프로덕션 환경 모두) -urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) - # 정적 파일 서빙 (개발 환경에서만) if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) diff --git a/B_main/urls.py b/B_main/urls.py index 8857691..20f680b 100644 --- a/B_main/urls.py +++ b/B_main/urls.py @@ -1,7 +1,5 @@ from django.urls import path from . import views -from django.conf import settings -from django.conf.urls.static import static urlpatterns = [ path('', views.main, name='main'), @@ -14,7 +12,4 @@ urlpatterns = [ path('session_logout/', views.session_logout, name='session_logout'), path('signup/', views.signup_view, name='signup'), path('privacy-policy/', views.privacy_policy, name='privacy_policy'), -] - -# 미디어 파일 서빙 (개발 및 프로덕션 환경 모두) -urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file +] \ No newline at end of file diff --git a/B_main/views.py b/B_main/views.py index 33e8352..cf01da4 100644 --- a/B_main/views.py +++ b/B_main/views.py @@ -144,12 +144,19 @@ def search_people(request): base_filter = Person.objects.all() # 현재 사용자의 권한에 따라 추가 필터 적용 - if current_user_person and not current_user_person.모든사람보기권한: - # 모든사람보기권한이 False인 경우 회원가입한 사람만 표시 (user가 있는 사람들) + print(f"[DEBUG] 검색 - 사용자: {request.user.username}, 슈퍼유저: {request.user.is_superuser}") + print(f"[DEBUG] 검색 - current_user_person: {current_user_person}") + + # 슈퍼유저이거나 Person 객체가 없는 경우 모든 사람 표시 + if request.user.is_superuser or current_user_person is None: + print(f"[DEBUG] 검색 - 슈퍼유저 또는 Person 객체 없음 - 모든 사람 표시 모드") + # 모든 사람 표시 (필터 추가 없음) + elif current_user_person and not current_user_person.모든사람보기권한: + # 모든사람보기권한이 False인 경우 회원가입한 사람만 표시 base_filter = base_filter.filter(user__isnull=False) print(f"[DEBUG] 검색 - 회원가입자만 표시 모드: {current_user_person.이름}") else: - print(f"[DEBUG] 검색 - 모든 사람 표시 모드") + print(f"[DEBUG] 검색 - 모든 사람 표시 모드 (모든사람보기권한: {current_user_person.모든사람보기권한})") if query: # 이름, 소속, 직책, 키워드로 검색