Enhance Admin UI: Singleton PlatformProfile and Sidebar Icons
This commit is contained in:
parent
bd260781ff
commit
73bbc63c0c
@ -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",
|
||||
|
||||
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user