ticket and comment count and badge and new notif

This commit is contained in:
Parsa Nazer
2025-02-05 01:36:21 +03:30
parent d4d06493fb
commit 8700fde8a4
4 changed files with 40 additions and 3 deletions
+2
View File
@@ -119,6 +119,7 @@ UNFOLD = {
"title": _("نظرات"),
"icon": "chat",
"link": reverse_lazy("admin:product_commentmodel_changelist"),
"badge": "utils.admin.comment_count",
},
{
"title": _("قیمت دلار"),
@@ -210,6 +211,7 @@ UNFOLD = {
"title": _("تیکت"),
"icon": "confirmation_number",
"link": reverse_lazy("admin:ticket_ticket_changelist"),
"badge": "utils.admin.new_ticket_count",
},
],
+5
View File
@@ -8,6 +8,9 @@ from django.utils.translation import gettext_lazy as _
from django.views.generic import RedirectView, TemplateView
from unfold.views import UnfoldModelAdminViewMixin
from order.models import OrderModel
from ticket.models import Ticket
class HomeView(RedirectView):
pattern_name = "admin:index"
@@ -16,8 +19,10 @@ class HomeView(RedirectView):
def dashboard_callback(request, context):
pending_count = OrderModel.objects.filter(status='ADMIN_PENDING').count()
open_tickets_count = Ticket.objects.filter(status__in=['open', 'in_progress']).count()
context.update(random_data())
context.update({'pending_count': pending_count})
context.update({'open_tickets_count': open_tickets_count})
return context
+23 -2
View File
@@ -5,8 +5,8 @@
<div class="flex flex-col lg:flex-row lg:items-center">
<h2 class="font-semibold text-font-important-light text-base dark:text-font-important-dark flex items-center">
<span class="material-symbols-outlined md-18 mr-3 w-4.5 align-middle">notifications</span>
<span class="align-middle">سفارش جدید داری</span>
<span class="text-white bg-primary-600 py-1 px-2 rounded" style="margin-right: 10px;">{{ pending_count }} </span>
<span class="align-middle" style="margin-right: 8px;">سفارش جدید داری</span>
<span class="text-white bg-primary-800 py-1 px-2 rounded" style="margin-right: 8px;">{{ pending_count }} </span>
</h2>
</div>
@@ -18,4 +18,25 @@
{% endcomponent %}
</div>
</div>
{% endif %}
{% if open_tickets_count%}
<div dir='rtl' class="bg-base-50 border border-base-200 border-dashed flex flex-col gap-4 p-4 rounded dark:bg-white/[.02] dark:border-base-700 lg:flex-row lg:justify-between w-full shrink-0 lg:items-center" style="justify-content: space-between;">
<div class="flex flex-col lg:flex-row lg:items-center">
<h2 class="font-semibold text-font-important-light text-base dark:text-font-important-dark flex items-center">
<span class="material-symbols-outlined md-18 mr-3 w-4.5 align-middle">confirmation_number</span>
<span class="align-middle" style="margin-right: 8px;">تیکت جدید داری</span>
<span class="text-white bg-primary-800 py-1 px-2 rounded" style="margin-right: 8px;">{{ open_tickets_count }} </span>
</h2>
</div>
<div class="flex lg:flex-row lg:items-center">
{% component "unfold/components/flex.html" with class="flex-col gap-4 lg:flex-row" %}
{% component "unfold/components/button.html" with href="/admin/ticket/ticket/" %}
نمایش تیکت ها
{% endcomponent %}
{% endcomponent %}
</div>
</div>
{% endif %}
+10 -1
View File
@@ -1,5 +1,8 @@
from order.models import OrderModel
from product.models import DollorModel
from product.models import DollorModel, CommentModel
from ticket.models import Ticket
def admin_pending_count(request):
pending_count = OrderModel.objects.filter(status='ADMIN_PENDING').count()
return str(pending_count)
@@ -7,3 +10,9 @@ def admin_pending_count(request):
def dollor_price(request):
dollor_object, _ = DollorModel.objects.get_or_create(unique_filed='unique')
return str(dollor_object.price)[:2]
def comment_count(request):
return CommentModel.objects.all().count()
def new_ticket_count(request):
return Ticket.objects.filter(status__in=['open', 'in_progress']).count()