From 236c69fbc833d7159bfe55d139dad8d8bc44a335 Mon Sep 17 00:00:00 2001 From: vickytechkey Date: Sun, 20 Sep 2026 21:24:49 +0530 Subject: [PATCH] feat: add email logs view, template, and dashboard link --- mailer/templates/mailer/dashboard.html | 2 +- mailer/templates/mailer/logs.html | 53 ++++++++++++++++++++++++++ mailer/urls.py | 1 + mailer/views.py | 4 ++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 mailer/templates/mailer/logs.html diff --git a/mailer/templates/mailer/dashboard.html b/mailer/templates/mailer/dashboard.html index d72d9c1..a319696 100644 --- a/mailer/templates/mailer/dashboard.html +++ b/mailer/templates/mailer/dashboard.html @@ -27,7 +27,7 @@

Logs

View sent/received emails

- View Logs + View Logs
diff --git a/mailer/templates/mailer/logs.html b/mailer/templates/mailer/logs.html new file mode 100644 index 0000000..35ea55f --- /dev/null +++ b/mailer/templates/mailer/logs.html @@ -0,0 +1,53 @@ +{% extends "mailer/base.html" %} + +{% block content %} +
+
+
+
+

Email Logs

+ Back to Dashboard +
+ +
+ +
+ + + + + + + + + + + + + {% for log in logs %} + + + + + + + + + {% empty %} + + + + {% endfor %} + +
Sent AtRecipientSubjectTemplateStatusError
{{ log.sent_at|date:"Y-m-d H:i:s" }}{{ log.recipient }}{{ log.subject }}{{ log.template_name }} + {% if log.status == 'success' %} + Success + {% else %} + Failed + {% endif %} + {{ log.error_message|default:"-" }}
No email logs found.
+
+
+
+
+{% endblock %} diff --git a/mailer/urls.py b/mailer/urls.py index 092bd1a..a183adb 100644 --- a/mailer/urls.py +++ b/mailer/urls.py @@ -4,4 +4,5 @@ from . import views urlpatterns = [ path('', views.dashboard, name='dashboard'), path('test-email/', views.send_test_email, name='send_test_email'), + path('logs/', views.view_logs, name='view_logs'), ] diff --git a/mailer/views.py b/mailer/views.py index 8d54822..a0ff417 100644 --- a/mailer/views.py +++ b/mailer/views.py @@ -80,3 +80,7 @@ def send_test_email(request): return redirect('dashboard') return render(request, 'mailer/send_test.html') + +def view_logs(request): + logs = EmailLog.objects.all().order_by('-sent_at') + return render(request, 'mailer/logs.html', {'logs': logs})