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: # 이름, 소속, 직책, 키워드로 검색