From 73bbc63c0c57bcb6db508a0f61a17c87962d1102 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 1 Feb 2026 02:41:14 +0000 Subject: [PATCH] Enhance Admin UI: Singleton PlatformProfile and Sidebar Icons --- config/settings.py | 11 ++++++----- core/admin.py | 9 ++++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/config/settings.py b/config/settings.py index 26833e2..0fe21f9 100644 --- a/config/settings.py +++ b/config/settings.py @@ -254,8 +254,6 @@ JAZZMIN_SETTINGS = { "topmenu_links": [ {"name": "Home", "url": "admin:index", "permissions": ["auth.view_user"]}, {"name": "View Website", "url": "index", "new_window": True}, - {"model": "auth.User"}, - {"app": "core"}, ], "usermenu_links": [ {"model": "auth.User"} @@ -269,13 +267,16 @@ JAZZMIN_SETTINGS = { "auth": "fas fa-users-cog", "auth.user": "fas fa-user", "auth.Group": "fas fa-users", - "core.Parcel": "fas fa-box", + "core.Parcel": "fas fa-box-open", "core.Profile": "fas fa-id-card", - "core.PlatformProfile": "fas fa-building", + "core.PlatformProfile": "fas fa-cogs", "core.Country": "fas fa-globe", "core.City": "fas fa-city", + "core.Governate": "fas fa-map-marked-alt", "core.DriverRating": "fas fa-star", - "core.Testimonial": "fas fa-comment", + "core.Testimonial": "fas fa-comment-dots", + "core.NotificationTemplate": "fas fa-envelope-open-text", + "core.PricingRule": "fas fa-tags", }, "default_icon_parents": "fas fa-chevron-circle-right", "default_icon_children": "fas fa-circle", diff --git a/core/admin.py b/core/admin.py index e0bc4e2..429f449 100644 --- a/core/admin.py +++ b/core/admin.py @@ -4,7 +4,7 @@ from django.contrib.auth.models import User from .models import Profile, Parcel, Country, Governate, City, PlatformProfile, Testimonial, DriverRating, NotificationTemplate, PricingRule from django.utils.translation import gettext_lazy as _ from django.urls import path, reverse -from django.shortcuts import render +from django.shortcuts import render, redirect from django.utils.html import format_html from django.contrib import messages from .whatsapp_utils import send_whatsapp_message_detailed @@ -193,6 +193,13 @@ class PlatformProfileAdmin(admin.ModelAdmin): if self.model.objects.exists(): return False return super().has_add_permission(request) + + def changelist_view(self, request, extra_context=None): + # Redirect directly to the change page if a profile exists + profile = self.model.objects.first() + if profile: + return redirect('admin:core_platformprofile_change', profile.pk) + return super().changelist_view(request, extra_context) def get_urls(self): urls = super().get_urls()