minor update

This commit is contained in:
2025-08-25 15:14:20 +05:30
parent 7272f1726f
commit 8bfa53a7b8
9 changed files with 82 additions and 8 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
-1
View File
@@ -61,7 +61,6 @@ class IssueCategory(models.Model):
def __str__(self):
return self.name
# issues/models.py
class Issue(models.Model):
STATUS_REPORTED = 'reported'
STATUS_ACKNOWLEDGED = 'acknowledged'
+14 -2
View File
@@ -75,6 +75,7 @@
</ul>
<!-- 🔥 ADD THE DROPDOWN CODE RIGHT HERE 🔥 -->
<!-- Right side -->
<div class="d-flex">
{% if user.is_authenticated %}
<div class="dropdown">
@@ -82,10 +83,18 @@
<i class="fas fa-user me-1"></i> {{ user.username }}
</button>
<ul class="dropdown-menu dropdown-menu-end">
{% if user.is_citizen %}
<li>
<a class="dropdown-item" href="{% url 'citizen_dashboard' %}">Dashboard</a>
<a class="dropdown-item" href="{% url 'citizen_dashboard' %}">Citizen Dashboard</a>
</li>
<li><a class="dropdown-item" href="#">Profile</a></li>
{% endif %}
{% if user.is_resolver %}
<li>
<a class="dropdown-item" href="{% url 'department_dashboard' %}">Department Dashboard</a>
</li>
{% endif %}
{% if user.is_superuser %}
<li>
<a class="dropdown-item text-danger fw-bold" href="{% url 'superadmin_dashboard' %}">
@@ -93,6 +102,7 @@
</a>
</li>
{% endif %}
<li>
<hr class="dropdown-divider" />
</li>
@@ -105,10 +115,12 @@
</ul>
</div>
{% else %}
<!-- Login / Register buttons for anonymous users -->
<a href="{% url 'login' %}" class="btn btn-outline-light me-2">Login</a>
<a href="{% url 'register' %}" class="btn btn-primary">Register</a>
{% endif %}
</div>
</div>
</div>
</nav>
@@ -0,0 +1,56 @@
{% extends "core/base.html" %}
{% block content %}
<div class="container my-5">
<div class="card shadow-lg">
<div class="card-header bg-primary text-white">
<h3>Department Dashboard</h3>
<p>Welcome, {{ request.user.username }}. Your Departments:
{% for dept in departments %} {{ dept.name }}{% if not forloop.last %}, {% endif %}{% endfor %}
</p>
</div>
<div class="card-body">
{% if issues %}
<table class="table table-bordered table-hover">
<thead class="table-light">
<tr>
<th>#</th>
<th>Title</th>
<th>Category</th>
<th>Reported By</th>
<th>Status</th>
<th>Created At</th>
</tr>
</thead>
<tbody>
{% for issue in issues %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ issue.title }}</td>
<td>{{ issue.category.name|default:"—" }}</td>
<td>{{ issue.reporter.username }}</td>
<td>
{% if issue.status == "reported" %}
<span class="badge bg-danger">Reported</span>
{% elif issue.status == "acknowledged" %}
<span class="badge bg-info text-dark">Acknowledged</span>
{% elif issue.status == "in_progress" %}
<span class="badge bg-warning text-dark">In Progress</span>
{% elif issue.status == "resolved" %}
<span class="badge bg-success">Resolved</span>
{% else %}
<span class="badge bg-secondary">Unknown</span>
{% endif %}
</td>
<td>{{ issue.created_at|date:"M d, Y H:i" }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="text-muted">No issues assigned to your departments yet.</p>
{% endif %}
</div>
</div>
</div>
{% endblock %}
@@ -1,4 +1,3 @@
<!-- core/templates/core/superadmin_dashboard.html -->
{% extends "core/base.html" %}
{% block content %}
+2 -2
View File
@@ -9,7 +9,6 @@ urlpatterns = [
path("superadmin/departments/<int:pk>/", views.department_detail, name="department_detail"),
path("superadmin/manage/", views.manage_issues, name="manage_issues"),
path("superadmin/assign-department/<int:issue_id>/", views.assign_department, name="assign_department"),
path('register/', views.register, name='register'),
path('login/', views.custom_login, name='login'),
path('logout/', auth_views.LogoutView.as_view(), name='logout'),
@@ -19,5 +18,6 @@ urlpatterns = [
path("issues/<int:pk>/", views.issue_detail, name="issue_detail"),
path("issues/<int:pk>/comment/", views.add_comment, name="add_comment"),
path("issues/<int:pk>/comment/<int:parent_id>/", views.add_comment, name="add_comment"),
path('vote/<int:issue_id>/', views.vote_issue, name='vote_issue'),
path('vote/<int:issue_id>/', views.vote_issue, name='vote_issue'),
path("department/", views.department_dashboard, name="department_dashboard"),
]
+10 -2
View File
@@ -239,7 +239,7 @@ def department_detail(request, pk):
email=email,
password=password
)
user.is_staff = True
user.is_resolver = True
user.save()
department.users.add(user)
messages.success(request, f"User '{username}' created and added to department.")
@@ -301,4 +301,12 @@ def assign_department(request, issue_id):
else:
messages.error(request, "Please select a department.")
return redirect("manage_issues") # redirect back to the issues page
return redirect("manage_issues")
def resolver_check(user):
return user.is_resolver
@login_required
@user_passes_test(resolver_check)
def department_dashboard(request):
return render(request, "dashboard/department_dashboard.html")