feat: add email logs view, template, and dashboard link
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 30s
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 30s
This commit is contained in:
parent
f726078ac2
commit
236c69fbc8
4 changed files with 59 additions and 1 deletions
|
|
@ -27,7 +27,7 @@
|
|||
<div class="card-content">
|
||||
<p class="title is-4">Logs</p>
|
||||
<p class="subtitle is-6">View sent/received emails</p>
|
||||
<a href="#" class="button is-info is-fullwidth" disabled>View Logs</a>
|
||||
<a href="{% url 'view_logs' %}" class="button is-info is-fullwidth">View Logs</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
53
mailer/templates/mailer/logs.html
Normal file
53
mailer/templates/mailer/logs.html
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
{% extends "mailer/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="columns is-centered">
|
||||
<div class="column is-10">
|
||||
<div class="box">
|
||||
<div class="is-flex is-justify-content-space-between is-align-items-center mb-4">
|
||||
<h1 class="title is-3 mb-0">Email Logs</h1>
|
||||
<a href="{% url 'dashboard' %}" class="button is-light">Back to Dashboard</a>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="table-container">
|
||||
<table class="table is-fullwidth is-striped is-hoverable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sent At</th>
|
||||
<th>Recipient</th>
|
||||
<th>Subject</th>
|
||||
<th>Template</th>
|
||||
<th>Status</th>
|
||||
<th>Error</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for log in logs %}
|
||||
<tr>
|
||||
<td>{{ log.sent_at|date:"Y-m-d H:i:s" }}</td>
|
||||
<td>{{ log.recipient }}</td>
|
||||
<td>{{ log.subject }}</td>
|
||||
<td>{{ log.template_name }}</td>
|
||||
<td>
|
||||
{% if log.status == 'success' %}
|
||||
<span class="tag is-success">Success</span>
|
||||
{% else %}
|
||||
<span class="tag is-danger">Failed</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ log.error_message|default:"-" }}</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="6" class="has-text-centered">No email logs found.</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
@ -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'),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -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})
|
||||
|
|
|
|||
Loading…
Reference in a new issue