From 2459ccbb6d8a499067cb7c6c6a61323bcedeb33a Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Thu, 18 Dec 2025 21:28:33 +0545 Subject: [PATCH] feat(src): add notifications API endpoint - **New Features**: - Added new URL route for notifications under `/notifications/` endpoint - Integrated `src.api.notifications.urls` module into the main URL configuration ``` --- src/api/notifications/urls.py | 11 +++++++++ src/api/notifications/views.py | 41 ++++++++++++++++++++++++++++++++++ src/urls.py | 1 + 3 files changed, 53 insertions(+) diff --git a/src/api/notifications/urls.py b/src/api/notifications/urls.py index e69de29..aa3f8a4 100644 --- a/src/api/notifications/urls.py +++ b/src/api/notifications/urls.py @@ -0,0 +1,11 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path("", views.notifications_dashboard, name="notifications_dashboard"), + path("list/", views.notification_list, name="notification_list"), + path("/detail/", views.notification_detail, name="notification_detail"), +] + + diff --git a/src/api/notifications/views.py b/src/api/notifications/views.py index e69de29..81a4d7c 100644 --- a/src/api/notifications/views.py +++ b/src/api/notifications/views.py @@ -0,0 +1,41 @@ +from django.shortcuts import get_object_or_404, render + +from src.models.notifications import Notification + + +def notifications_dashboard(request): + recent_notifications = Notification.objects.all()[:10] + pending_count = Notification.objects.filter(status="PENDING").count() + failed_count = Notification.objects.filter(status="FAILED").count() + sent_count = Notification.objects.filter(status="SENT").count() + + return render( + request, + "notifications/dashboard.html", + { + "recent_notifications": recent_notifications, + "pending_count": pending_count, + "failed_count": failed_count, + "sent_count": sent_count, + }, + ) + + +def notification_list(request): + notifications = Notification.objects.all() + return render( + request, + "notifications/notification_list.html", + {"notifications": notifications}, + ) + + +def notification_detail(request, pk): + notification = get_object_or_404(Notification, pk=pk) + return render( + request, + "notifications/notification_detail.html", + {"notification": notification}, + ) + + diff --git a/src/urls.py b/src/urls.py index a2d229f..247be64 100644 --- a/src/urls.py +++ b/src/urls.py @@ -12,4 +12,5 @@ urlpatterns = [ path("projects/", include("src.api.projects.urls")), path("finance/", include("src.api.finance.urls")), path("productivity/", include("src.api.productivity.urls")), + path("notifications/", include("src.api.notifications.urls")), ]