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 ```
This commit is contained in:
3 files changed
+53
No files matched your search
@@ -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("<int:pk>/detail/", views.notification_detail, name="notification_detail"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -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},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -12,4 +12,5 @@ urlpatterns = [
|
|||||||
path("projects/", include("src.api.projects.urls")),
|
path("projects/", include("src.api.projects.urls")),
|
||||||
path("finance/", include("src.api.finance.urls")),
|
path("finance/", include("src.api.finance.urls")),
|
||||||
path("productivity/", include("src.api.productivity.urls")),
|
path("productivity/", include("src.api.productivity.urls")),
|
||||||
|
path("notifications/", include("src.api.notifications.urls")),
|
||||||
]
|
]
|
||||||
Reference in new issue
Block a user