dashboard fixed

This commit is contained in:
Faheedkhan 2025-08-28 13:46:43 +03:00
parent 966633fe3b
commit f670015e39
5 changed files with 45 additions and 39 deletions

View File

@ -10,8 +10,8 @@ urlpatterns = [
# main URLs # main URLs
path("", views.WelcomeView, name="welcome"), path("", views.WelcomeView, name="welcome"),
path("signup/", views.dealer_signup, name="account_signup"), path("signup/", views.dealer_signup, name="account_signup"),
path("", views.HomeView.as_view(), name="home"), path("", views.HomeView, name="home"),
path("<slug:dealer_slug>/", views.HomeView.as_view(), name="home"), path("<slug:dealer_slug>/", views.HomeView, name="home"),
# Tasks # Tasks
path("legal/", views.terms_and_privacy, name="terms_and_privacy"), path("legal/", views.terms_and_privacy, name="terms_and_privacy"),
# path('tasks/<int:task_id>/detail/', views.task_detail, name='task_detail'), # path('tasks/<int:task_id>/detail/', views.task_detail, name='task_detail'),

View File

@ -362,24 +362,31 @@ def dealer_signup(request):
"account/signup-wizard.html", "account/signup-wizard.html",
) )
class HomeView(LoginRequiredMixin, TemplateView): # class HomeView(LoginRequiredMixin, TemplateView):
""" # """
HomeView class responsible for rendering the home page. # HomeView class responsible for rendering the home page.
This class ensures that only authenticated users can access the home page. # This class ensures that only authenticated users can access the home page.
Unauthenticated users are redirected to the welcome page. It is built on top of # Unauthenticated users are redirected to the welcome page. It is built on top of
Django's TemplateView and includes additional functionality by inheriting from # Django's TemplateView and includes additional functionality by inheriting from
LoginRequiredMixin. The purpose of this class is to control the accessibility # LoginRequiredMixin. The purpose of this class is to control the accessibility
of the main index page of the application and manage context data for frontend # of the main index page of the application and manage context data for frontend
rendering. # rendering.
:ivar template_name: The path to the template used for rendering the view's # :ivar template_name: The path to the template used for rendering the view's
output. # output.
:type template_name: str # :type template_name: str
""" # """
template_name = "index.html" # template_name = "index.html"
@login_required
def HomeView(request,dealer_slug=None):
dealer_slug=request.dealer.slug
if request.is_sales and not request.is_manager and not request.is_dealer:
return redirect('sales_dashboard', dealer_slug=dealer_slug)
else:
return redirect('general_dashboard',dealer_slug=dealer_slug)
class TestView(TemplateView): class TestView(TemplateView):
""" """

View File

@ -8,13 +8,13 @@
<div class="main-content flex-grow-1 container-fluid mt-4 mb-3"> <div class="main-content flex-grow-1 container-fluid mt-4 mb-3">
<div class="d-flex flex-column flex-md-row justify-content-between align-items-md-center mb-5 pb-3 border-bottom"> <div class="d-flex flex-column flex-md-row justify-content-between align-items-md-center mb-5 pb-3 border-bottom">
<h2 class="h3 fw-bold mb-3 mb-md-0"> <h2 class="h3 fw-bold mb-3 mb-md-0">
{% if request.is_dealer or request.is_manager%} {% if request.is_dealer %}
{% trans "Business Health Dashboard" %} {% trans "Business Health Dashboard" %}
{% endif %} {% elif request.is_manger %}
{% if request.is_inventory and not request.is_manager and not request.is_dealer %} {% trans "Manager Dashboard" %}
{% elif request.is_inventory %}
{% trans "Inventory Dashboard" %} {% trans "Inventory Dashboard" %}
{% endif %} {% else %}
{% if request.is_accountant and not request.is_manager and not request.is_dealer %}
{% trans "Accountant Dashboard" %} {% trans "Accountant Dashboard" %}
{% endif %} {% endif %}
<i class="fas fa-chart-area text-primary ms-2"></i> <i class="fas fa-chart-area text-primary ms-2"></i>

View File

@ -11,6 +11,7 @@
hx-swap="outerHTML" hx-swap="outerHTML"
hx-select-oob="#toast-container" hx-select-oob="#toast-container"
hx-indicator="#spinner"> hx-indicator="#spinner">
<li class="nav-item"> <li class="nav-item">
{% comment %} <p class="navbar-vertical-label text-primary fs-8 text-truncate">{{request.dealer|default:"Apps"}}</p> {% comment %} <p class="navbar-vertical-label text-primary fs-8 text-truncate">{{request.dealer|default:"Apps"}}</p>
<hr class="navbar-vertical-line"> {% endcomment %} <hr class="navbar-vertical-line"> {% endcomment %}
@ -439,27 +440,23 @@
</div> </div>
</a> </a>
</li> </li>
<li class="nav-item">
<a class="nav-link" href="{% url 'ticket_list' request.dealer.slug %}">
<div class="d-flex align-items-center">
{% if user.is_authenticated %}
<span class="nav-link-icon"><span class="fa-solid fa-car"></span></span>
<span class="nav-link-text">{{ request.dealer.user.username }}</span>
{% endif %}
</div>
</a>
</li>
</ul> </ul>
</div> </div>
{% endif %} {% endif %}
</div> </div>
</div> </div>
<div class="navbar-vertical-footer"> <div class="navbar-vertical-footer">
<button class="btn navbar-vertical-toggle border-0 fw-semibold w-100 white-space-nowrap d-flex align-items-center"> <a class="nav-link ps-2" href="{% if request.is_dealer%}{% url 'ticket_list' request.dealer.slug %} {% else %}#{%endif%}">
<span class="fas fa-angle-double-left fs-8"></span><span class="fas fa-angle-double-right fs-8"></span><span class="navbar-vertical-footer-text ms-2">Collapsed View</span> <div class="d-flex align-items-center">
</button> {% if user.is_authenticated%}
<span class="nav-link-icon"><span class="fa-solid fa-gear me-1 fs-5"></span></span>
<span class="nav-link-text">{{ request.dealer.user.username }}</span>
{% endif %}
</div>
</a>
</div> </div>
</nav> </nav>
<nav class="navbar navbar-top fixed-top navbar-expand" id="navbarDefault"> <nav class="navbar navbar-top fixed-top navbar-expand" id="navbarDefault">

View File

@ -1,5 +1,5 @@
{% extends 'base.html' %} {% comment %} {% extends 'base.html' %}
{% load i18n static custom_filters django_ledger %} {% load i18n static custom_filters django_ledger %}
{% block content %} {% block content %}
@ -19,5 +19,7 @@
<p>Loading dashboard...</p> <p>Loading dashboard...</p>
</div> </div>
</div> </div>
{% endif %} {% endif %}
{% endblock %}
{% endblock %} {% endcomment %}