From 2c0c85c74f27d801e7ab22c42285227be77243a0 Mon Sep 17 00:00:00 2001 From: Faheedkhan Date: Thu, 4 Sep 2025 16:35:33 +0300 Subject: [PATCH] title and notification history update --- inventory/models.py | 1 + inventory/tasks.py | 4 +- inventory/views.py | 28 +++- templates/403.html | 2 +- templates/404.html | 2 +- templates/500.html | 2 +- templates/account/password_change.html | 4 +- templates/account/password_reset.html | 4 +- templates/account/password_reset_done.html | 4 +- .../account/password_reset_from_key.html | 4 +- .../account/password_reset_from_key_done.html | 4 +- templates/admin_management/auth_logs.html | 2 +- .../confirm_activate_account.html | 18 +- templates/admin_management/management.html | 59 ++++--- templates/admin_management/model_logs.html | 2 +- .../permenant_delete_account.html | 18 +- templates/admin_management/request_logs.html | 2 +- templates/chart_of_accounts/coa_create.html | 3 + templates/chart_of_accounts/coa_list.html | 3 + templates/chart_of_accounts/coa_update.html | 3 + templates/crm/employee_calendar.html | 3 + templates/crm/leads/lead_detail.html | 3 + templates/crm/notifications_history.html | 158 +++++++++++++----- .../dashboards/aging_inventory_list.html | 3 + templates/dashboards/sales_dashboard.html | 3 + templates/haikalbot/chat.html | 2 +- templates/header.html | 23 ++- templates/inventory/car_list.html | 3 + templates/inventory/list.html | 3 + templates/inventory/transfer_preview.html | 2 +- templates/items/service/service_list.html | 2 - templates/ledger/bills/bill_update_form.html | 2 +- .../ledger/coa_accounts/account_form.html | 37 ++-- .../journal_entry/journal_entry_delete.html | 49 ++++-- .../journal_entry/journal_entry_form.html | 2 +- .../journal_entry/journal_entry_list.html | 6 +- .../journal_entry_transactions.html | 2 +- .../journal_entry/journal_entry_txs.html | 3 + templates/ledger/ledger/ledger_delete.html | 47 ++++-- templates/ledger/ledger/ledger_detail.html | 3 + templates/ledger/reports/car_sale_report.html | 2 +- templates/purchase_orders/po_delete.html | 3 + templates/purchase_orders/po_detail.html | 3 + templates/purchase_orders/po_list.html | 2 +- templates/purchase_orders/po_update.html | 3 + templates/purchase_orders/po_upload_cars.html | 5 +- templates/sales/estimates/estimate_form.html | 2 +- .../sales/estimates/estimate_preview.html | 2 +- .../sales/estimates/sale_order_form.html | 2 +- .../sales/estimates/sale_order_preview.html | 2 +- templates/sales/invoices/invoice_create.html | 2 +- templates/sales/invoices/invoice_preview.html | 2 +- templates/staff/staff_detail.html | 2 +- templates/support/create_ticket.html | 3 + templates/support/ticket_list.html | 28 +++- templates/support/ticket_update.html | 48 ++++-- templates/tours/start_tour.html | 2 +- templates/tours/tour_list.html | 2 +- templates/users/user_detail.html | 2 +- templates/users/user_group_form.html | 2 +- templates/users/user_password_reset.html | 3 + 61 files changed, 437 insertions(+), 210 deletions(-) diff --git a/inventory/models.py b/inventory/models.py index b8ed7462..0237332c 100644 --- a/inventory/models.py +++ b/inventory/models.py @@ -829,6 +829,7 @@ class Car(Base): def mark_as_sold(self): self.cancel_reservation() self.status = CarStatusChoices.SOLD + self.sold_date=timezone.now() self.save() def cancel_reservation(self): diff --git a/inventory/tasks.py b/inventory/tasks.py index 729fc65d..7fca2852 100644 --- a/inventory/tasks.py +++ b/inventory/tasks.py @@ -985,7 +985,9 @@ def send_schedule_reminder_email(schedule_id): """ try: schedule = Schedule.objects.get(pk=schedule_id) - + if schedule.completed: + logger.info("Schedule is already completed, existing.") + return # Ensure the user has an email and the schedule is not completed/canceled if not schedule.scheduled_by.email or schedule.status in [ "completed", diff --git a/inventory/views.py b/inventory/views.py index ed729dec..36f4920d 100644 --- a/inventory/views.py +++ b/inventory/views.py @@ -1402,7 +1402,7 @@ class CarListView(LoginRequiredMixin, PermissionRequiredMixin, ListView): template_name = "inventory/car_list_view.html" context_object_name = "cars" paginate_by = 10 - permission_required = "inventory.view_carcolors" + permission_required = "inventory.view_car" def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -1422,7 +1422,6 @@ class CarListView(LoginRequiredMixin, PermissionRequiredMixin, ListView): context["year"] = models.Car.objects.none() make = self.request.GET.get("make") model = self.request.GET.get("model") - if make: make_ = models.CarMake.objects.get(id_car_make=int(make)) context["model"] = make_.carmodel_set.filter(car__in=cars).distinct() @@ -1440,15 +1439,16 @@ class CarListView(LoginRequiredMixin, PermissionRequiredMixin, ListView): dealer = get_user_type(self.request) qs = super().get_queryset() qs = qs.filter(dealer=dealer) - status = self.request.GET.get("status") + # status = self.request.GET.get("status") search = self.request.GET.get("search") make = self.request.GET.get("make", None) model = self.request.GET.get("model", None) year = self.request.GET.get("year", None) car_status = self.request.GET.get("car_status", None) + print("ALLLLLLLLL:::",make,model) - if status: - qs = qs.filter(status=status) + if car_status: + qs = qs.filter(status=car_status) if search: query = ( Q(vin__icontains=search) @@ -4990,6 +4990,7 @@ def create_estimate(request, dealer_slug, slug=None): .annotate(hash_count=Count("hash")) .distinct() ) + print(car_list) context = { "form": form, "items": [ @@ -5124,8 +5125,7 @@ def create_sale_order(request, dealer_slug, pk): f"KeyError: 'car_info' or 'status' key missing when attempting to update status to 'sold' for item.item_model PK: {getattr(item.item_model, 'pk', 'N/A')}." ) pass - item.item_model.car.sold_date=timezone.now() # to be checked added by faheed - item.item_model.car.save()# to be checked added byfaheed + item.item_model.car.mark_as_sold() messages.success(request, "Sale Order created successfully") @@ -7539,6 +7539,18 @@ class NotificationListView(LoginRequiredMixin, ListView): def get_queryset(self): return models.Notification.objects.filter(user=self.request.user) + + def get_context_data(self, **kwargs): + + context = super().get_context_data(**kwargs) + user_notifications = self.get_queryset() + + # Calculate the number of total, read and unread notifications + context['total_count'] = user_notifications.count() + context['read_count'] = user_notifications.filter(is_read=True).count() + context['unread_count'] = user_notifications.filter(is_read=False).count() + + return context class ItemServiceCreateView( @@ -8198,7 +8210,7 @@ def send_email_view(request, dealer_slug, pk): تحياتي، -{dealer.get_local_name} +{dealer.get_local_name()} {dealer.phone_number} Haikal | هيكل ----- diff --git a/templates/403.html b/templates/403.html index 8eb9a6c3..766aacaf 100644 --- a/templates/403.html +++ b/templates/403.html @@ -4,7 +4,7 @@ - 403 - Access Forbidden + 403 - {% trans "Access Forbidden" %}