From 1dfdf694ce544f53f6c58ed5572c6e943c052380 Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Wed, 18 Feb 2026 13:49:53 +0100 Subject: [PATCH] updated admin panel error where reload kicks you out --- backend/holy_backend/urls.py | 10 ++- frontend/src/pages/AdminDashboard.tsx | 114 +++++++++++++++----------- 2 files changed, 73 insertions(+), 51 deletions(-) diff --git a/backend/holy_backend/urls.py b/backend/holy_backend/urls.py index aec8d25..ce0dbf7 100644 --- a/backend/holy_backend/urls.py +++ b/backend/holy_backend/urls.py @@ -5,12 +5,16 @@ from rest_framework.authtoken.views import obtain_auth_token from django.conf import settings from django.conf.urls.static import static from django.views.static import serve -from django.views.generic.base import TemplateView +from django.views.static import serve +from django.conf import settings import os # Clean the admin path admin_url = os.environ.get('ADMIN_URL', 'admin').strip('/') +def serve_index(request, resource=None): + return serve(request, 'index.html', document_root=settings.STATIC_ROOT) + urlpatterns = [ # Robots.txt path('robots.txt', TemplateView.as_view(template_name="robots.txt", content_type="text/plain")), @@ -24,4 +28,8 @@ urlpatterns = [ path('api/schema/swagger-ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'), path('api/schema/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'), path('media/', serve, {'document_root': settings.MEDIA_ROOT}), + + # Catch-all for React Frontend + path('', serve_index, name='index'), + path('', serve_index), ] diff --git a/frontend/src/pages/AdminDashboard.tsx b/frontend/src/pages/AdminDashboard.tsx index 3d328df..240aaac 100644 --- a/frontend/src/pages/AdminDashboard.tsx +++ b/frontend/src/pages/AdminDashboard.tsx @@ -274,57 +274,71 @@ const AdminDashboard: React.FC = () => { {currentTab === 2 && ( {t('admin.banners')} - - {banners.map((banner) => ( - - - {banner.is_active && ( - } - label="Active" - color="success" - size="small" - sx={{ position: 'absolute', top: 12, right: 12, zIndex: 2 }} - /> - )} - - {banner.name} - {banner.description} - - - Settings: -
-                                                {JSON.stringify(banner.settings, null, 2)}
-                                            
+ + {banners.length === 0 ? ( + + No banner models found in the database. + + + ) : ( + + {banners.map((banner) => ( + + + {banner.is_active && ( + } + label="Active" + color="success" + size="small" + sx={{ position: 'absolute', top: 12, right: 12, zIndex: 2 }} + /> + )} + + {banner.name} + {banner.description} + + + Settings: +
+                                                    {JSON.stringify(banner.settings, null, 2)}
+                                                
+
+
+ + + + + -
- - - - - - -
-
- ))} -
+ + + ))} + + )}
)}