241 lines
14 KiB
HTML
241 lines
14 KiB
HTML
{% extends "portal_base.html" %}
|
|
{% load static i18n %}
|
|
|
|
{% block title %}{% trans "Messages" %}{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h4 class="mb-0 text-primary-theme">{% trans "Messages" %}</h4>
|
|
<a href="{% url 'message_create' %}" class="btn btn-main-action">
|
|
<i class="fas fa-plus"></i> {% trans "Compose Message" %}
|
|
</a>
|
|
</div>
|
|
|
|
<div class="card mb-4 border-primary-theme-subtle">
|
|
<div class="card-body">
|
|
<form method="get" class="row g-3">
|
|
<div class="col-md-3">
|
|
<label for="status" class="form-label">{% trans "Status" %}</label>
|
|
<select name="status" id="status" class="form-select">
|
|
<option value="">{% trans "All Status" %}</option>
|
|
<option value="read" {% if status_filter == 'read' %}selected{% endif %}>{% trans "Read" %}</option>
|
|
<option value="unread" {% if status_filter == 'unread' %}selected{% endif %}>{% trans "Unread" %}</option>
|
|
</select>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<label for="type" class="form-label">{% trans "Type" %}</label>
|
|
<select name="type" id="type" class="form-select">
|
|
<option value="">{% trans "All Types" %}</option>
|
|
<option value="GENERAL" {% if type_filter == 'GENERAL' %}selected{% endif %}>{% trans "General" %}</option>
|
|
<option value="JOB_RELATED" {% if type_filter == 'JOB_RELATED' %}selected{% endif %}>{% trans "Job Related" %}</option>
|
|
<option value="INTERVIEW" {% if type_filter == 'INTERVIEW' %}selected{% endif %}>{% trans "Interview" %}</option>
|
|
<option value="OFFER" {% if type_filter == 'OFFER' %}selected{% endif %}>{% trans "Offer" %}</option>
|
|
</select>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<label for="q" class="form-label">{% trans "Search" %}</label>
|
|
<div class="input-group">
|
|
<input type="text" name="q" id="q" class="form-control"
|
|
value="{{ search_query }}" placeholder="{% trans 'Search messages...' %}">
|
|
<button class="btn btn-outline-primary-theme" type="submit">
|
|
<i class="fas fa-search"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<label class="form-label"> </label>
|
|
<button type="submit" class="btn btn-main-action w-100">
|
|
<i class="fa-solid fa-filter me-1"></i>{% trans "Filter" %}
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-3">
|
|
<div class="col-md-6">
|
|
<div class="card bg-primary-theme-subtle border-primary-theme-subtle">
|
|
<div class="card-body">
|
|
<h6 class="card-title text-primary-theme">{% trans "Total Messages" %}</h6>
|
|
<h3 class="text-primary-theme">{{ total_messages }}</h3>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="card bg-warning-subtle border-warning-subtle">
|
|
<div class="card-body">
|
|
<h6 class="card-title text-warning">{% trans "Unread Messages" %}</h6>
|
|
<h3 class="text-warning">{{ unread_messages }}</h3>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card border-primary-theme-subtle">
|
|
<div class="card-body">
|
|
{% if page_obj %}
|
|
<div class="table-responsive">
|
|
<table class="table table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>{% trans "Subject" %}</th>
|
|
<th>{% trans "Sender" %}</th>
|
|
<th>{% trans "Recipient" %}</th>
|
|
<th>{% trans "Type" %}</th>
|
|
<th>{% trans "Status" %}</th>
|
|
<th>{% trans "Created" %}</th>
|
|
<th>{% trans "Actions" %}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for message in page_obj %}
|
|
<tr class="{% if not message.is_read %}table-secondary-theme-light{% endif %}">
|
|
<td>
|
|
<a href="{% url 'message_detail' message.id %}"
|
|
class="fw-bold text-primary-theme text-decoration-none">
|
|
{{ message.subject|truncatechars:50 }}
|
|
</a>
|
|
{% if message.parent_message %}
|
|
<span class="badge bg-secondary ms-2">Reply</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{% if message.sender == request.user %}
|
|
{% trans "Me"%}
|
|
{% else %}
|
|
{{ message.sender.get_full_name|default:message.sender.username }}
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{% if message.recipient == request.user %}
|
|
{% trans "Me"%}
|
|
{% else %}
|
|
{{ message.recipient.get_full_name|default:message.recipient.username }}
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
<td>
|
|
<span>
|
|
{{ message.get_message_type_display }}
|
|
</span>
|
|
</td>
|
|
<td>
|
|
{% if message.is_read %}
|
|
<span class="badge bg-primary-theme">{% trans "Read" %}</span>
|
|
{% else %}
|
|
<span class="badge bg-warning">{% trans "Unread" %}</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>{{ message.created_at|date:"M d, Y H:i" }}</td>
|
|
<td>
|
|
<div class="btn-group" role="group">
|
|
<a href="{% url 'message_detail' message.id %}"
|
|
class="btn btn-sm btn-outline-primary" title="{% trans 'View' %}">
|
|
<i class="fas fa-eye"></i>
|
|
</a>
|
|
{% if not message.is_read and message.recipient == request.user %}
|
|
<a href="{% url 'message_mark_read' message.id %}"
|
|
class="btn btn-sm btn-outline-success"
|
|
title="Mark as Read">
|
|
<i class="fas fa-check"></i>
|
|
</a>
|
|
{% endif %}
|
|
<a href="{% url 'message_reply' message.id %}"
|
|
class="btn btn-sm btn-outline-primary" title="{% trans 'Reply' %}">
|
|
<i class="fas fa-reply"></i>
|
|
</a>
|
|
{% comment %} <a href="{% url 'message_delete' message.id %}"
|
|
class="btn btn-sm btn-outline-danger"
|
|
hx-post="{% url 'message_delete' message.id %}"
|
|
hx-confirm="{% trans 'Are you sure you want to delete this message?' %}"
|
|
title="{% trans 'Delete' %}">
|
|
<i class="fas fa-trash"></i>
|
|
</a> {% endcomment %}
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% empty %}
|
|
<tr>
|
|
<td colspan="7" class="text-center text-muted">
|
|
<i class="fas fa-inbox fa-3x mb-3 text-primary-theme"></i>
|
|
<p class="mb-0">{% trans "No messages found." %}</p>
|
|
<p class="small">{% trans "Try adjusting your filters or compose a new message." %}</p>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
{% if page_obj.has_other_pages %}
|
|
<nav aria-label="Message pagination">
|
|
<ul class="pagination justify-content-center">
|
|
{% if page_obj.has_previous %}
|
|
<li class="page-item">
|
|
<a class="page-link text-primary-theme" href="?page={{ page_obj.previous_page_number }}&status={{ status_filter }}&type={{ type_filter }}&q={{ search_query }}">
|
|
<i class="fas fa-chevron-left"></i>
|
|
</a>
|
|
</li>
|
|
{% endif %}
|
|
|
|
{% for num in page_obj.paginator.page_range %}
|
|
{% if page_obj.number == num %}
|
|
<li class="page-item active">
|
|
<span class="page-link bg-primary-theme border-primary-theme">{{ num }}</span>
|
|
</li>
|
|
{% else %}
|
|
<li class="page-item">
|
|
<a class="page-link text-primary-theme" href="?page={{ num }}&status={{ status_filter }}&type={{ type_filter }}&q={{ search_query }}">{{ num }}</a>
|
|
</li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% if page_obj.has_next %}
|
|
<li class="page-item">
|
|
<a class="page-link text-primary-theme" href="?page={{ page_obj.next_page_number }}&status={{ status_filter }}&type={{ type_filter }}&q={{ search_query }}">
|
|
<i class="fas fa-chevron-right"></i>
|
|
</a>
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
</nav>
|
|
{% endif %}
|
|
{% else %}
|
|
<div class="text-center text-muted py-5">
|
|
<i class="fas fa-inbox fa-3x mb-3 text-primary-theme"></i>
|
|
<p class="mb-0">{% trans "No messages found." %}</p>
|
|
<p class="small">{% trans "Try adjusting your filters or compose a new message." %}</p>
|
|
<a href="{% url 'message_create' %}" class="btn btn-main-action">
|
|
<i class="fas fa-plus"></i> {% trans "Compose Message" %}
|
|
</a>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block customJS %}
|
|
<script>
|
|
// Auto-refresh unread count every 30 seconds
|
|
/*setInterval(() => {
|
|
fetch('/api/unread-count/')
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
// Update unread count in navigation if it exists
|
|
const unreadBadge = document.querySelector('.unread-messages-count');
|
|
if (unreadBadge) {
|
|
unreadBadge.textContent = data.unread_count;
|
|
unreadBadge.style.display = data.unread_count > 0 ? 'inline-block' : 'none';
|
|
}
|
|
})
|
|
.catch(error => console.error('Error fetching unread count:', error));
|
|
}, 30000);
|
|
*/
|
|
</script>
|
|
{% endblock %} |