initial commit
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>
|
||||
Civixfix - {% block title %}Community Issue Reporting Platform{% endblock %}
|
||||
</title>
|
||||
<!-- Bootstrap 5 CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" />
|
||||
<link rel="preload" as="image" href="https://a.tile.openstreetmap.org/13/4521/2632.png">
|
||||
<link rel="preload" as="image" href="https://b.tile.openstreetmap.org/13/4521/2632.png">
|
||||
|
||||
<link rel="preload" as="font"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/webfonts/fa-solid-900.woff2" type="font/woff2"
|
||||
crossorigin>
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" />
|
||||
<!-- Custom CSS -->
|
||||
<style>
|
||||
.hero-section {
|
||||
background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)),
|
||||
url("https://images.unsplash.com/photo-1477959858617-67f85cf4f1df?ixlib=rb-4.0.3");
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
color: white;
|
||||
padding: 100px 0;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.feature-icon {
|
||||
font-size: 2.5rem;
|
||||
margin-bottom: 1rem;
|
||||
color: #0d6efd;
|
||||
}
|
||||
|
||||
.issue-card {
|
||||
transition: transform 0.3s;
|
||||
}
|
||||
|
||||
.issue-card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
</style>
|
||||
{% block extra_css %}{% endblock %}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- Navigation -->
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark sticky-top">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="{% url 'home' %}">
|
||||
<i class="fas fa-bullhorn me-2"></i>Civixfix
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav me-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="{% url 'home' %}">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#features">Features</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#how-it-works">How It Works</a>
|
||||
</li>
|
||||
{% if user.is_authenticated and user.is_citizen %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'citizen_dashboard' %}">Dashboard</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
<div class="d-flex">
|
||||
{% if user.is_authenticated %}
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-outline-light dropdown-toggle" type="button" data-bs-toggle="dropdown">
|
||||
<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' %}">
|
||||
<i class="fas fa-users me-2 text-primary"></i>Citizen Dashboard</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if user.is_resolver %}
|
||||
<li>
|
||||
<a class="dropdown-item" href="{% url 'department_dashboard' %}">
|
||||
<i class="fas fa-building me-2 text-success"></i>Department Dashboard</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if user.is_superuser %}
|
||||
<li>
|
||||
<a class="dropdown-item text-danger fw-bold" href="{% url 'superadmin_dashboard' %}">
|
||||
<i class="fas fa-crown me-1 text-warning fw-bold"></i> Super Admin
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
<li>
|
||||
<hr class="dropdown-divider" />
|
||||
</li>
|
||||
<li>
|
||||
<form method="post" action="{% url 'logout' %}">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="dropdown-item"><i class="fas fa-right-from-bracket me-2"></i>Logout</button>
|
||||
</form>
|
||||
</li>
|
||||
</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>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main>{% block content %}{% endblock %}</main>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer class="text-black py-4 mt-5">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-4 mb-3">
|
||||
<h5><i class="fas fa-bullhorn me-2"></i>Civixfix</h5>
|
||||
<p class="text-muted">
|
||||
Empowering communities through transparent issue reporting and
|
||||
resolution.
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-4 mb-3">
|
||||
<h5>Quick Links</h5>
|
||||
<ul class="list-unstyled">
|
||||
<li>
|
||||
<a href="#features" class="text-decoration-none text-muted">Features</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#how-it-works" class="text-decoration-none text-muted">How It Works</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="text-decoration-none text-muted">Privacy Policy</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-4 mb-3">
|
||||
<h5>Contact</h5>
|
||||
<ul class="list-unstyled text-muted">
|
||||
<li>
|
||||
<i class="fas fa-envelope me-2"></i> gokuldevse2001@gmail.com
|
||||
</li>
|
||||
<li><i class="fas fa-phone me-2"></i> +91 8129329073</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="my-4 bg-secondary" />
|
||||
<div class="text-center text-muted">
|
||||
<small>© {% now "Y" %} Civixfix. All rights reserved.</small>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- Bootstrap 5 JS Bundle with Popper -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<!-- jQuery -->
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
{% block extra_js %}{% endblock %}
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,297 @@
|
||||
{% extends "core/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<!-- Hero Section -->
|
||||
<section class="hero-section text-center">
|
||||
<div class="container">
|
||||
<h1 class="display-4 fw-bold mb-4">Report. Resolve. Rejoice.</h1>
|
||||
<p class="lead mb-5">Your voice matters in making our community better. Report local issues and track their
|
||||
resolution in real-time.</p>
|
||||
<div class="d-grid gap-2 d-sm-flex justify-content-sm-center">
|
||||
{% if user.is_authenticated %}
|
||||
<a href="{% url 'citizen_dashboard' %}" class="btn btn-primary btn-lg px-4 gap-3">Report an Issue</a>
|
||||
{% else %}
|
||||
<a href="{% url 'login' %}" class="btn btn-primary btn-lg px-4 gap-3">Report an Issue</a>
|
||||
{% endif %}
|
||||
<a href="#how-it-works" class="btn btn-outline-light btn-lg px-4">Learn More</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Stats Section -->
|
||||
<section class="container mb-5">
|
||||
<div class="row text-center">
|
||||
<div class="col-md-3">
|
||||
<h3 class="fw-bold text-primary">{{ total_issues|default:"0" }}+</h3>
|
||||
<p class="text-muted">Issues Reported</p>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<h3 class="fw-bold text-primary">{{ resolved_issues|default:"0" }}+</h3>
|
||||
<p class="text-muted">Issues Resolved</p>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<h3 class="fw-bold text-primary">{{ active_users|default:"0" }}+</h3>
|
||||
<p class="text-muted">Active Users</p>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<h3 class="fw-bold text-primary">{{ total_departments|default:"0" }}</h3>
|
||||
<p class="text-muted">Municipal Departments</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
<!-- Features Section -->
|
||||
<section id="features" class="container mb-5">
|
||||
<div class="text-center mb-5">
|
||||
<h2 class="fw-bold">Why Choose Civixfix?</h2>
|
||||
<p class="lead text-muted">Transparent, efficient, and community-driven problem solving</p>
|
||||
</div>
|
||||
<div class="row g-4">
|
||||
<div class="col-md-4">
|
||||
<div class="card h-100 border-0 shadow-sm">
|
||||
<div class="card-body text-center p-4">
|
||||
<div class="feature-icon">
|
||||
<i class="fas fa-map-marked-alt"></i>
|
||||
</div>
|
||||
<h5 class="card-title">Location-Based Reporting</h5>
|
||||
<p class="card-text text-muted">Pinpoint issues on an interactive map for accurate location tracking
|
||||
and faster resolution.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card h-100 border-0 shadow-sm">
|
||||
<div class="card-body text-center p-4">
|
||||
<div class="feature-icon">
|
||||
<i class="fas fa-tasks"></i>
|
||||
</div>
|
||||
<h5 class="card-title">Real-Time Tracking</h5>
|
||||
<p class="card-text text-muted">Follow your reported issues through every stage from reporting to
|
||||
resolution.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card h-100 border-0 shadow-sm">
|
||||
<div class="card-body text-center p-4">
|
||||
<div class="feature-icon">
|
||||
<i class="fas fa-users"></i>
|
||||
</div>
|
||||
<h5 class="card-title">Community Engagement</h5>
|
||||
<p class="card-text text-muted">Vote and comment on issues to help prioritize what matters most to
|
||||
your neighborhood.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- How It Works Section -->
|
||||
<section id="how-it-works" class="bg-light py-5 mb-5">
|
||||
<div class="container">
|
||||
<div class="text-center mb-5">
|
||||
<h2 class="fw-bold">How Civixfix Works</h2>
|
||||
<p class="lead text-muted">Simple steps to make your community better</p>
|
||||
</div>
|
||||
<div class="row g-4">
|
||||
<div class="col-md-4">
|
||||
<div class="card h-100 border-0 shadow-sm">
|
||||
<div class="card-body text-center p-4">
|
||||
<span class="badge bg-primary rounded-circle mb-3"
|
||||
style="width: 50px; height: 50px; line-height: 50px; font-size: 1.5rem;">1</span>
|
||||
<h5 class="card-title">Report an Issue</h5>
|
||||
<p class="card-text text-muted">Take a photo, add details, and drop a pin on the map to report
|
||||
problems in your area.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card h-100 border-0 shadow-sm">
|
||||
<div class="card-body text-center p-4">
|
||||
<span class="badge bg-primary rounded-circle mb-3"
|
||||
style="width: 50px; height: 50px; line-height: 50px; font-size: 1.5rem;">2</span>
|
||||
<h5 class="card-title">Community Support</h5>
|
||||
<p class="card-text text-muted">Others can vote and comment to show support and add details to
|
||||
your report.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card h-100 border-0 shadow-sm">
|
||||
<div class="card-body text-center p-4">
|
||||
<span class="badge bg-primary rounded-circle mb-3"
|
||||
style="width: 50px; height: 50px; line-height: 50px; font-size: 1.5rem;">3</span>
|
||||
<h5 class="card-title">Official Response</h5>
|
||||
<p class="card-text text-muted">Municipal authorities receive, prioritize, and work on resolving
|
||||
the issues.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Recent Issues Section -->
|
||||
<section class="container mb-5">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2 class="fw-bold">Recently Reported Issues</h2>
|
||||
{% if user.is_authenticated %}
|
||||
<a href="{% url 'view_all_issues' %}" class="btn btn-primary">View All Issues</a>
|
||||
{% else %}
|
||||
<a href="{% url 'login' %}" class="btn btn-outline-primary">View All Issues</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="row g-4">
|
||||
{% for issue in recent_issues %}
|
||||
<div class="col-md-4">
|
||||
<div class="card issue-card h-100">
|
||||
{% if issue.photo %}
|
||||
<img src="{{ issue.photo.url }}" class="card-img-top" alt="{{ issue.title }}"
|
||||
style="height: 200px; object-fit: cover;">
|
||||
{% else %}
|
||||
<img src="https://via.placeholder.com/300x200/6c757d/ffffff?text=No+Image" class="card-img-top"
|
||||
alt="No image">
|
||||
{% endif %}
|
||||
<div class="card-body">
|
||||
<span class="badge
|
||||
{% if issue.department.name == 'Roads & Transportation' %} bg-primary
|
||||
{% elif issue.department.name == 'Sanitation & Waste Management' %} bg-success
|
||||
{% elif issue.department.name == 'Public Safety' %} bg-danger
|
||||
{% elif issue.department.name == 'Water & Sewage' %} bg-info text-dark
|
||||
{% elif issue.department.name == 'Parks & Recreation' %} bg-warning text-dark
|
||||
{% elif issue.department.name == 'Electricity & Utilities' %} bg-dark
|
||||
{% elif issue.department.name == 'Environmental Services' %} bg-secondary
|
||||
{% elif issue.department.name == 'Public Works' %} bg-teal text-white
|
||||
{% else %} bg-light text-dark
|
||||
{% endif %} mb-2">
|
||||
{{ issue.department.name|default:"General" }}
|
||||
</span>
|
||||
<h5 class="card-title">{{ issue.title|truncatewords:5 }}</h5>
|
||||
<p class="card-text text-muted">{{ issue.description|truncatewords:15 }}</p>
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<small class="text-muted"><i class="fas fa-map-marker-alt me-1"></i> {{ issue.location|truncatewords:2 }}</small>
|
||||
|
||||
<!-- Vote Button -->
|
||||
<div class="vote-section">
|
||||
{% if user.is_authenticated %}
|
||||
<button
|
||||
class="btn btn-sm btn-outline-primary vote-btn {% if issue.user_has_voted %}active{% endif %}"
|
||||
data-issue-id="{{ issue.id }}">
|
||||
<i class="fas fa-thumbs-up"></i>
|
||||
<span class="vote-count">{{ issue.vote_count }}</span>
|
||||
</button>
|
||||
{% else %}
|
||||
<a href="{% url 'login' %}" class="btn btn-sm btn-outline-primary">
|
||||
<i class="fas fa-thumbs-up"></i>
|
||||
<span class="vote-count">{{ issue.vote_count }}</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer bg-transparent">
|
||||
<small
|
||||
class="text-{% if issue.status == 'resolved' %}success{% elif issue.status == 'in_progress' %}warning{% else %}info{% endif %}">
|
||||
<i
|
||||
class="fas fa-{% if issue.status == 'resolved' %}check-circle{% elif issue.status == 'in_progress' %}tasks{% else %}clock{% endif %} me-1"></i>
|
||||
{{ issue.get_status_display }}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% empty %}
|
||||
<div class="col-12 text-center py-5">
|
||||
<i class="fas fa-inbox fa-3x text-muted mb-3"></i>
|
||||
<h4>No issues reported yet</h4>
|
||||
<p class="text-muted">Be the first to report an issue in your community!</p>
|
||||
<a href="{% url 'login' %}" class="btn btn-primary">Get Started</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Call to Action -->
|
||||
<section class="bg-primary text-white py-5">
|
||||
<div class="container text-center">
|
||||
<h2 class="fw-bold mb-4">Ready to make a difference in your community?</h2>
|
||||
<p class="lead mb-4">Join {{ active_users|default:"thousands of" }} citizens who are actively improving their
|
||||
neighborhoods.</p>
|
||||
{% if user.is_authenticated %}
|
||||
<a href="{% url 'citizen_dashboard' %}" class="btn btn-light btn-lg px-4">Report an Issue</a>
|
||||
{% else %}
|
||||
<a href="{% url 'login' %}" class="btn btn-light btn-lg px-4">Get Started Now</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
// Vote functionality
|
||||
$('.vote-btn').click(function () {
|
||||
const issueId = $(this).data('issue-id');
|
||||
const button = $(this);
|
||||
|
||||
// Show loading state
|
||||
const originalHtml = button.html();
|
||||
button.prop('disabled', true);
|
||||
button.html('<i class="fas fa-spinner fa-spin"></i>');
|
||||
|
||||
// Send vote request
|
||||
$.ajax({
|
||||
url: "{% url 'vote_issue' 0 %}".replace('0', issueId),
|
||||
type: 'POST',
|
||||
headers: {
|
||||
'X-CSRFToken': '{{ csrf_token }}'
|
||||
},
|
||||
success: function (response) {
|
||||
if (response.success) {
|
||||
// Update button state
|
||||
if (response.voted) {
|
||||
button.addClass('active');
|
||||
} else {
|
||||
button.removeClass('active');
|
||||
}
|
||||
|
||||
// Update vote count
|
||||
button.find('.vote-count').text(response.vote_count);
|
||||
|
||||
// Update button text
|
||||
button.html('<i class="fas fa-thumbs-up"></i> <span class="vote-count">' + response.vote_count + '</span>');
|
||||
} else {
|
||||
alert('Error: ' + response.error);
|
||||
button.html(originalHtml);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
alert('Error voting. Please try again.');
|
||||
button.html(originalHtml);
|
||||
},
|
||||
complete: function () {
|
||||
button.prop('disabled', false);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.vote-btn.active {
|
||||
background-color: #0d6efd;
|
||||
color: white;
|
||||
border-color: #0d6efd;
|
||||
}
|
||||
|
||||
.vote-btn:hover:not(:disabled) {
|
||||
transform: scale(1.05);
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.vote-btn:disabled {
|
||||
opacity: 0.7;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,54 @@
|
||||
{% extends "core/base.html" %}
|
||||
|
||||
{% block title %}Login{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container py-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card shadow">
|
||||
<div class="card-body p-5">
|
||||
<h2 class="card-title text-center mb-4">Login to Your Account</h2>
|
||||
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
<div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
|
||||
{{ message }}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="id_username" class="form-label">Username</label>
|
||||
<input type="text" name="username" class="form-control" id="id_username" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label for="id_password" class="form-label">Password</label>
|
||||
<input type="password" name="password" class="form-control" id="id_password" required>
|
||||
</div>
|
||||
|
||||
<div class="d-grid mb-3">
|
||||
<button type="submit" class="btn btn-primary btn-lg">Login</button>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<a href="#" class="text-decoration-none">Forgot password?</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<hr class="my-4">
|
||||
|
||||
<p class="text-center text-muted">
|
||||
Don't have an account? <a href="{% url 'register' %}" class="text-decoration-none">Register here</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,62 @@
|
||||
{% extends "core/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container my-5">
|
||||
<div class="card shadow-lg">
|
||||
<div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
|
||||
<h3>Manage Citizens</h3>
|
||||
<a href="{% url 'superadmin_dashboard' %}" class="btn btn-light btn-sm">Back to Dashboard</a>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
{% if citizens %}
|
||||
<table class="table table-striped table-hover">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>No.</th>
|
||||
<th>Username</th>
|
||||
<th>Email</th>
|
||||
<th>Phone No.</th>
|
||||
<th>Date Joined</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for citizen in citizens %}
|
||||
<tr>
|
||||
<td>{{ forloop.counter }}</td>
|
||||
<td>{{ citizen.username }}</td>
|
||||
<td>{{ citizen.email }}</td>
|
||||
<td>{{ citizen.phone }}</td>
|
||||
<td>{{ citizen.date_joined|date:"M d, Y" }}</td>
|
||||
<td>
|
||||
{% if citizen.is_currently_banned %}
|
||||
<span class="badge bg-danger">Banned until {{ citizen.banned_until|date:"M d, Y" }}</span>
|
||||
{% else %}
|
||||
<span class="badge bg-success">Active</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if citizen.is_currently_banned %}
|
||||
<a href="{% url 'unban_user' citizen.id %}" class="btn btn-sm btn-success">
|
||||
<i class="fas fa-unlock"></i> Unban
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{% url 'ban_user' citizen.id %}" class="btn btn-sm btn-danger">
|
||||
<i class="fas fa-ban"></i> Ban
|
||||
</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% else %}
|
||||
<p class="text-muted">No citizen users found.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,103 @@
|
||||
{% extends "core/base.html" %}
|
||||
{% block title %}Register as Citizen{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container py-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card shadow">
|
||||
<div class="card-body p-5">
|
||||
<h2 class="card-title text-center mb-4">Create Citizen Account</h2>
|
||||
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
|
||||
{# Messages block - FIXED SYNTAX #}
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
<div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
|
||||
{{ message }}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{# Form errors block - FIXED SYNTAX #}
|
||||
{% if form.errors %}
|
||||
<div class="alert alert-danger">
|
||||
<strong>Error!</strong> Please correct the following:
|
||||
<ul>
|
||||
{% for field, errors in form.errors.items %}
|
||||
{% for error in errors %}
|
||||
<li>{{ error }}</li>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="id_username" class="form-label">Username</label>
|
||||
{{ form.username }}
|
||||
<small class="text-muted">Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.</small>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="id_email" class="form-label">Email</label>
|
||||
{{ form.email }}
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="id_phone" class="form-label">Phone (Optional)</label>
|
||||
{{ form.phone }}
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="id_password1" class="form-label">Password</label>
|
||||
{{ form.password1 }}
|
||||
<small class="text-muted">
|
||||
<ul>
|
||||
<li>Your password can't be too similar to your other personal information.</li>
|
||||
<li>Your password must contain at least 8 characters.</li>
|
||||
<li>Your password can't be a commonly used password.</li>
|
||||
<li>Your password can't be entirely numeric.</li>
|
||||
</ul>
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label for="id_password2" class="form-label">Password Confirmation</label>
|
||||
{{ form.password2 }}
|
||||
<small class="text-muted">Enter the same password as before, for verification.</small>
|
||||
</div>
|
||||
|
||||
<div class="d-grid">
|
||||
<button type="submit" class="btn btn-primary btn-lg">Register</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<hr class="my-4">
|
||||
|
||||
<p class="text-center text-muted">
|
||||
Already have an account? <a href="{% url 'login' %}" class="text-decoration-none">Login here</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
// Add Bootstrap classes to all input fields
|
||||
$('input:not([type="checkbox"]):not([type="radio"])').addClass('form-control');
|
||||
$('input[type="checkbox"]').removeClass('form-control').addClass('form-check-input');
|
||||
$('input[type="radio"]').removeClass('form-control').addClass('form-check-input');
|
||||
|
||||
// Add Bootstrap classes to select fields
|
||||
$('select').addClass('form-select');
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,91 @@
|
||||
{% extends "core/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container my-5">
|
||||
<div class="card shadow-lg">
|
||||
<div class="card-header bg-warning text-dark">
|
||||
<h3>Analytics & Reports</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
<h5>Total Issues Reported:
|
||||
<span class="badge bg-dark">{{ total_issues }}</span>
|
||||
</h5>
|
||||
|
||||
<canvas id="statusChart" height="120" class="mt-4"></canvas>
|
||||
<canvas id="deptChart" height="120" class="mt-4"></canvas>
|
||||
<canvas id="citizenChart" height="120" class="mt-4"></canvas>
|
||||
<canvas id="trendChart" height="120" class="mt-4"></canvas>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
|
||||
{# Safely pass JSON to JS #}
|
||||
{{ status_counts|json_script:"status-data" }}
|
||||
{{ top_departments|json_script:"dept-data" }}
|
||||
{{ top_citizens|json_script:"citizen-data" }}
|
||||
{{ issues_last_30_days|json_script:"trend-data" }}
|
||||
|
||||
<script>
|
||||
const statusCounts = JSON.parse(document.getElementById("status-data").textContent);
|
||||
const deptCounts = JSON.parse(document.getElementById("dept-data").textContent);
|
||||
const citizenCounts = JSON.parse(document.getElementById("citizen-data").textContent);
|
||||
const trendCounts = JSON.parse(document.getElementById("trend-data").textContent);
|
||||
|
||||
// Status chart
|
||||
new Chart(document.getElementById('statusChart'), {
|
||||
type: 'pie',
|
||||
data: {
|
||||
labels: statusCounts.map(item => item.status),
|
||||
datasets: [{
|
||||
data: statusCounts.map(item => item.count),
|
||||
backgroundColor: ['#dc3545', '#0dcaf0', '#ffc107', '#198754']
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
// Department chart
|
||||
new Chart(document.getElementById('deptChart'), {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: deptCounts.map(item => item.department__name),
|
||||
datasets: [{
|
||||
label: 'Issues by Department',
|
||||
data: deptCounts.map(item => item.count),
|
||||
backgroundColor: '#0d6efd'
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
// Citizens chart
|
||||
new Chart(document.getElementById('citizenChart'), {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: citizenCounts.map(item => item.reporter__username),
|
||||
datasets: [{
|
||||
label: 'Top Citizens',
|
||||
data: citizenCounts.map(item => item.count),
|
||||
backgroundColor: '#6610f2'
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
// Issues over time
|
||||
new Chart(document.getElementById('trendChart'), {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: trendCounts.map(item => item.day),
|
||||
datasets: [{
|
||||
label: 'Issues Last 30 Days',
|
||||
data: trendCounts.map(item => item.count),
|
||||
borderColor: '#fd7e14',
|
||||
fill: false,
|
||||
tension: 0.2
|
||||
}]
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user