Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d834885e59 |
Binary file not shown.
BIN
core/__pycache__/forms.cpython-311.pyc
Normal file
BIN
core/__pycache__/forms.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +1,41 @@
|
||||
from django.contrib import admin
|
||||
from .models import Voter, VotingRecord, Donation, VoterContact, EventParticipation
|
||||
|
||||
# Register your models here.
|
||||
class VotingRecordInline(admin.TabularInline):
|
||||
model = VotingRecord
|
||||
extra = 1
|
||||
|
||||
class DonationInline(admin.TabularInline):
|
||||
model = Donation
|
||||
extra = 1
|
||||
|
||||
class VoterContactInline(admin.TabularInline):
|
||||
model = VoterContact
|
||||
extra = 1
|
||||
|
||||
class EventParticipationInline(admin.TabularInline):
|
||||
model = EventParticipation
|
||||
extra = 1
|
||||
|
||||
@admin.register(Voter)
|
||||
class VoterAdmin(admin.ModelAdmin):
|
||||
list_display = ('voter_id', 'last_name', 'first_name', 'district', 'precinct', 'candidate_support')
|
||||
list_filter = ('candidate_support', 'yard_sign_status', 'district')
|
||||
search_fields = ('voter_id', 'last_name', 'first_name', 'email')
|
||||
inlines = [VotingRecordInline, DonationInline, VoterContactInline, EventParticipationInline]
|
||||
|
||||
@admin.register(VotingRecord)
|
||||
class VotingRecordAdmin(admin.ModelAdmin):
|
||||
list_display = ('voter', 'election_date', 'description')
|
||||
|
||||
@admin.register(Donation)
|
||||
class DonationAdmin(admin.ModelAdmin):
|
||||
list_display = ('voter', 'donation_date', 'amount')
|
||||
|
||||
@admin.register(VoterContact)
|
||||
class VoterContactAdmin(admin.ModelAdmin):
|
||||
list_display = ('voter', 'contact_type', 'contact_date')
|
||||
|
||||
@admin.register(EventParticipation)
|
||||
class EventParticipationAdmin(admin.ModelAdmin):
|
||||
list_display = ('voter', 'event_type', 'event_date')
|
||||
49
core/forms.py
Normal file
49
core/forms.py
Normal file
@ -0,0 +1,49 @@
|
||||
from django import forms
|
||||
from .models import Voter, VotingRecord, Donation, VoterContact, EventParticipation
|
||||
|
||||
class VoterForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Voter
|
||||
fields = [
|
||||
'first_name', 'last_name', 'voter_id', 'address', 'phone', 'email',
|
||||
'district', 'precinct', 'registration_date', 'likelihood_to_vote',
|
||||
'candidate_support', 'yard_sign_status'
|
||||
]
|
||||
widgets = {
|
||||
'registration_date': forms.DateInput(attrs={'type': 'date'}),
|
||||
'address': forms.Textarea(attrs={'rows': 3}),
|
||||
}
|
||||
|
||||
class VotingRecordForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = VotingRecord
|
||||
fields = ['election_date', 'description', 'primary_party']
|
||||
widgets = {
|
||||
'election_date': forms.DateInput(attrs={'type': 'date'}),
|
||||
}
|
||||
|
||||
class DonationForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Donation
|
||||
fields = ['donation_date', 'amount', 'method']
|
||||
widgets = {
|
||||
'donation_date': forms.DateInput(attrs={'type': 'date'}),
|
||||
}
|
||||
|
||||
class VoterContactForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = VoterContact
|
||||
fields = ['contact_type', 'contact_date', 'description', 'notes']
|
||||
widgets = {
|
||||
'contact_date': forms.DateTimeInput(attrs={'type': 'datetime-local'}),
|
||||
'notes': forms.Textarea(attrs={'rows': 3}),
|
||||
}
|
||||
|
||||
class EventParticipationForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = EventParticipation
|
||||
fields = ['event_date', 'event_type', 'description']
|
||||
widgets = {
|
||||
'event_date': forms.DateInput(attrs={'type': 'date'}),
|
||||
'description': forms.Textarea(attrs={'rows': 3}),
|
||||
}
|
||||
70
core/migrations/0001_initial.py
Normal file
70
core/migrations/0001_initial.py
Normal file
@ -0,0 +1,70 @@
|
||||
# Generated by Django 5.2.7 on 2026-01-24 03:04
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Voter',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('voter_id', models.CharField(max_length=50, unique=True)),
|
||||
('first_name', models.CharField(max_length=100)),
|
||||
('last_name', models.CharField(max_length=100)),
|
||||
('address', models.TextField()),
|
||||
('phone', models.CharField(blank=True, max_length=20, null=True)),
|
||||
('email', models.EmailField(blank=True, max_length=254, null=True)),
|
||||
('district', models.CharField(blank=True, max_length=100, null=True)),
|
||||
('precinct', models.CharField(blank=True, max_length=100, null=True)),
|
||||
('registration_date', models.DateField(blank=True, null=True)),
|
||||
('likelihood_to_vote', models.IntegerField(choices=[(1, '1'), (2, '2'), (3, '3'), (4, '4'), (5, '5')], default=3)),
|
||||
('candidate_support', models.CharField(choices=[('unknown', 'Unknown'), ('supporting', 'Supporting'), ('not_supporting', 'Not Supporting')], default='unknown', max_length=20)),
|
||||
('yard_sign_status', models.CharField(choices=[('none', 'None'), ('wants', 'Wants a Yard Sign'), ('has', 'Has a Yard Sign')], default='none', max_length=20)),
|
||||
('latitude', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True)),
|
||||
('longitude', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
],
|
||||
options={
|
||||
'ordering': ['last_name', 'first_name'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Donation',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('donation_date', models.DateField()),
|
||||
('amount', models.DecimalField(decimal_places=2, max_digits=10)),
|
||||
('voter', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='donations', to='core.voter')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='VoterContact',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('contact_type', models.CharField(choices=[('Phone', 'Phone'), ('Door Visit', 'Door Visit'), ('Mail', 'Mail')], max_length=20)),
|
||||
('contact_date', models.DateTimeField()),
|
||||
('description', models.CharField(max_length=255)),
|
||||
('notes', models.TextField(blank=True, null=True)),
|
||||
('voter', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='contacts', to='core.voter')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='VotingRecord',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('election_date', models.DateField()),
|
||||
('description', models.CharField(max_length=255)),
|
||||
('primary_party', models.CharField(blank=True, max_length=50, null=True)),
|
||||
('voter', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='voting_records', to='core.voter')),
|
||||
],
|
||||
),
|
||||
]
|
||||
24
core/migrations/0002_eventparticipation.py
Normal file
24
core/migrations/0002_eventparticipation.py
Normal file
@ -0,0 +1,24 @@
|
||||
# Generated by Django 5.2.7 on 2026-01-24 03:23
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='EventParticipation',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('event_date', models.DateField()),
|
||||
('event_type', models.CharField(max_length=100)),
|
||||
('description', models.TextField(blank=True, null=True)),
|
||||
('voter', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='event_participations', to='core.voter')),
|
||||
],
|
||||
),
|
||||
]
|
||||
18
core/migrations/0003_donation_method.py
Normal file
18
core/migrations/0003_donation_method.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.2.7 on 2026-01-24 03:32
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0002_eventparticipation'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='donation',
|
||||
name='method',
|
||||
field=models.CharField(choices=[('Cash', 'Cash'), ('Check', 'Check'), ('Credit/Debit', 'Credit/Debit')], default='Check', max_length=20),
|
||||
),
|
||||
]
|
||||
BIN
core/migrations/__pycache__/0001_initial.cpython-311.pyc
Normal file
BIN
core/migrations/__pycache__/0001_initial.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
core/migrations/__pycache__/0003_donation_method.cpython-311.pyc
Normal file
BIN
core/migrations/__pycache__/0003_donation_method.cpython-311.pyc
Normal file
Binary file not shown.
@ -1,3 +1,95 @@
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
|
||||
# Create your models here.
|
||||
class Voter(models.Model):
|
||||
CANDIDATE_SUPPORT_CHOICES = [
|
||||
('unknown', 'Unknown'),
|
||||
('supporting', 'Supporting'),
|
||||
('not_supporting', 'Not Supporting'),
|
||||
]
|
||||
YARD_SIGN_CHOICES = [
|
||||
('none', 'None'),
|
||||
('wants', 'Wants a Yard Sign'),
|
||||
('has', 'Has a Yard Sign'),
|
||||
]
|
||||
LIKELIHOOD_CHOICES = [(i, str(i)) for i in range(1, 6)]
|
||||
|
||||
voter_id = models.CharField(max_length=50, unique=True)
|
||||
first_name = models.CharField(max_length=100)
|
||||
last_name = models.CharField(max_length=100)
|
||||
address = models.TextField()
|
||||
phone = models.CharField(max_length=20, blank=True, null=True)
|
||||
email = models.EmailField(blank=True, null=True)
|
||||
|
||||
# Demographics
|
||||
district = models.CharField(max_length=100, blank=True, null=True)
|
||||
precinct = models.CharField(max_length=100, blank=True, null=True)
|
||||
registration_date = models.DateField(blank=True, null=True)
|
||||
|
||||
# Engagement
|
||||
likelihood_to_vote = models.IntegerField(choices=LIKELIHOOD_CHOICES, default=3)
|
||||
candidate_support = models.CharField(max_length=20, choices=CANDIDATE_SUPPORT_CHOICES, default='unknown')
|
||||
yard_sign_status = models.CharField(max_length=20, choices=YARD_SIGN_CHOICES, default='none')
|
||||
|
||||
# Geocode (Optional for map integration later)
|
||||
latitude = models.DecimalField(max_digits=9, decimal_places=6, blank=True, null=True)
|
||||
longitude = models.DecimalField(max_digits=9, decimal_places=6, blank=True, null=True)
|
||||
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ['last_name', 'first_name']
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.first_name} {self.last_name} ({self.voter_id})"
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('voter_detail', kwargs={'pk': self.pk})
|
||||
|
||||
class VotingRecord(models.Model):
|
||||
voter = models.ForeignKey(Voter, on_delete=models.CASCADE, related_name='voting_records')
|
||||
election_date = models.DateField()
|
||||
description = models.CharField(max_length=255)
|
||||
primary_party = models.CharField(max_length=50, blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.voter.last_name} - {self.election_date}"
|
||||
|
||||
class Donation(models.Model):
|
||||
METHOD_CHOICES = [
|
||||
('Cash', 'Cash'),
|
||||
('Check', 'Check'),
|
||||
('Credit/Debit', 'Credit/Debit'),
|
||||
]
|
||||
voter = models.ForeignKey(Voter, on_delete=models.CASCADE, related_name='donations')
|
||||
donation_date = models.DateField()
|
||||
amount = models.DecimalField(max_digits=10, decimal_places=2)
|
||||
method = models.CharField(max_length=20, choices=METHOD_CHOICES, default='Check')
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.voter.last_name} - ${self.amount} ({self.method})"
|
||||
|
||||
class VoterContact(models.Model):
|
||||
CONTACT_TYPE_CHOICES = [
|
||||
('Phone', 'Phone'),
|
||||
('Door Visit', 'Door Visit'),
|
||||
('Mail', 'Mail'),
|
||||
]
|
||||
voter = models.ForeignKey(Voter, on_delete=models.CASCADE, related_name='contacts')
|
||||
contact_type = models.CharField(max_length=20, choices=CONTACT_TYPE_CHOICES)
|
||||
contact_date = models.DateTimeField()
|
||||
description = models.CharField(max_length=255)
|
||||
notes = models.TextField(blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.voter.last_name} - {self.contact_type} on {self.contact_date.date()}"
|
||||
|
||||
class EventParticipation(models.Model):
|
||||
voter = models.ForeignKey(Voter, on_delete=models.CASCADE, related_name='event_participations')
|
||||
event_date = models.DateField()
|
||||
event_type = models.CharField(max_length=100)
|
||||
description = models.TextField(blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.voter.last_name} - {self.event_type} on {self.event_date}"
|
||||
|
||||
@ -1,25 +1,75 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{% block title %}Knowledge Base{% endblock %}</title>
|
||||
{% if project_description %}
|
||||
<meta name="description" content="{{ project_description }}">
|
||||
<meta property="og:description" content="{{ project_description }}">
|
||||
<meta property="twitter:description" content="{{ project_description }}">
|
||||
{% endif %}
|
||||
{% if project_image_url %}
|
||||
<meta property="og:image" content="{{ project_image_url }}">
|
||||
<meta property="twitter:image" content="{{ project_image_url }}">
|
||||
{% endif %}
|
||||
{% load static %}
|
||||
<link rel="stylesheet" href="{% static 'css/custom.css' %}?v={{ deployment_timestamp }}">
|
||||
{% block head %}{% endblock %}
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{% block title %}Voter Campaign CRM{% endblock %}</title>
|
||||
|
||||
{% if project_description %}
|
||||
<meta name="description" content="{{ project_description }}">
|
||||
<meta property="og:description" content="{{ project_description }}">
|
||||
<meta property="twitter:description" content="{{ project_description }}">
|
||||
{% endif %}
|
||||
{% if project_image_url %}
|
||||
<meta property="og:image" content="{{ project_image_url }}">
|
||||
<meta property="twitter:image" content="{{ project_image_url }}">
|
||||
{% endif %}
|
||||
|
||||
{% load static %}
|
||||
<!-- Bootstrap 5 CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- Bootstrap Icons -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
|
||||
<!-- Custom Styles -->
|
||||
<link rel="stylesheet" href="{% static 'css/custom.css' %}?v={{ deployment_timestamp }}">
|
||||
|
||||
{% block head %}{% endblock %}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{% block content %}{% endblock %}
|
||||
</body>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark sticky-top">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="{% url 'index' %}">
|
||||
<i class="bi bi-person-check-fill me-2 text-primary"></i>Voter Campaign CRM
|
||||
</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 ms-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'index' %}">Dashboard</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/admin/">Admin Portal</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
</html>
|
||||
{% if messages %}
|
||||
<div class="container mt-3">
|
||||
{% 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" aria-label="Close"></button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<main>
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
|
||||
<footer class="bg-white py-4 mt-5 border-top">
|
||||
<div class="container text-center text-muted">
|
||||
<p class="small mb-0">© 2026 Voter Campaign CRM. Designed for Campaign Victory.</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- Bootstrap 5 JS Bundle -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
{% block scripts %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
@ -1,145 +1,88 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}{{ project_name }}{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--bg-color-start: #6a11cb;
|
||||
--bg-color-end: #2575fc;
|
||||
--text-color: #ffffff;
|
||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'><path d='M-10 10L110 10M10 -10L10 110' stroke-width='1' stroke='rgba(255,255,255,0.05)'/></svg>");
|
||||
animation: bg-pan 20s linear infinite;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
@keyframes bg-pan {
|
||||
0% {
|
||||
background-position: 0% 0%;
|
||||
}
|
||||
|
||||
100% {
|
||||
background-position: 100% 100%;
|
||||
}
|
||||
}
|
||||
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: var(--card-bg-color);
|
||||
border: 1px solid var(--card-border-color);
|
||||
border-radius: 16px;
|
||||
padding: 2.5rem 2rem;
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: clamp(2.2rem, 3vw + 1.2rem, 3.2rem);
|
||||
font-weight: 700;
|
||||
margin: 0 0 1.2rem;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0.5rem 0;
|
||||
font-size: 1.1rem;
|
||||
opacity: 0.92;
|
||||
}
|
||||
|
||||
.loader {
|
||||
margin: 1.5rem auto;
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border: 4px solid rgba(255, 255, 255, 0.25);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.runtime code {
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
padding: 0.15rem 0.45rem;
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
border: 0;
|
||||
}
|
||||
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 0.85rem;
|
||||
opacity: 0.75;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
{% extends 'base.html' %}
|
||||
{% load static %}
|
||||
|
||||
{% block content %}
|
||||
<main>
|
||||
<div class="card">
|
||||
<h1>Analyzing your requirements and generating your app…</h1>
|
||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||
<span class="sr-only">Loading…</span>
|
||||
<section class="hero-section">
|
||||
<div class="container text-center">
|
||||
<h1 class="display-4 mb-4">Voter Campaign CRM</h1>
|
||||
<p class="lead mb-5">Identify, Engaged, and Activate your base with a 360-degree voter view.</p>
|
||||
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<form action="{% url 'index' %}" method="GET" class="search-glass">
|
||||
<div class="input-group input-group-lg">
|
||||
<input type="text" name="q" class="form-control border-0" placeholder="Search by name or Voter ID..." value="{{ query|default:'' }}">
|
||||
<button class="btn btn-primary" type="submit">Search</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="hint">AppWizzy AI is collecting your requirements and applying the first changes.</p>
|
||||
<p class="hint">This page will refresh automatically as the plan is implemented.</p>
|
||||
<p class="runtime">
|
||||
Runtime: Django <code>{{ django_version }}</code> · Python <code>{{ python_version }}</code>
|
||||
— UTC <code>{{ current_time|date:"Y-m-d H:i:s" }}</code>
|
||||
</p>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: {{ current_time|date:"Y-m-d H:i:s" }} (UTC)
|
||||
</footer>
|
||||
{% endblock %}
|
||||
</section>
|
||||
|
||||
<div class="container py-5">
|
||||
<!-- Stats Row -->
|
||||
<div class="row mb-5">
|
||||
<div class="col-md-4">
|
||||
<div class="card stat-card p-4">
|
||||
<h5 class="text-muted">Total Voters</h5>
|
||||
<h2 class="mb-0">{{ stats.total_voters }}</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card stat-card p-4" style="border-left-color: var(--emerald-accent);">
|
||||
<h5 class="text-muted">Active Support</h5>
|
||||
<h2 class="mb-0">{{ stats.supporters }}</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card stat-card p-4" style="border-left-color: #F59E0B;">
|
||||
<h5 class="text-muted">Yard Signs</h5>
|
||||
<h2 class="mb-0">{{ stats.yard_signs }}</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Voter List -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2 class="h3">{% if query %}Search Results{% else %}Recent Voters{% endif %}</h2>
|
||||
<a href="/admin/core/voter/add/" class="btn btn-outline-primary btn-sm">+ Add New Voter</a>
|
||||
</div>
|
||||
|
||||
{% if voters %}
|
||||
<div class="row g-4">
|
||||
{% for voter in voters %}
|
||||
<div class="col-md-6 col-lg-4">
|
||||
<div class="card h-100 p-3">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<h5 class="mb-1">{{ voter.first_name }} {{ voter.last_name }}</h5>
|
||||
<p class="text-muted small mb-2">ID: {{ voter.voter_id }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<span class="badge {% if voter.candidate_support == 'supporting' %}bg-success{% elif voter.candidate_support == 'not_supporting' %}bg-danger{% else %}bg-secondary{% endif %}">
|
||||
{{ voter.get_candidate_support_display }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="small mb-3">
|
||||
<i class="bi bi-geo-alt"></i> {{ voter.address|truncatechars:40 }}
|
||||
</div>
|
||||
<div class="mt-auto">
|
||||
<a href="{{ voter.get_absolute_url }}" class="btn btn-light w-100 btn-sm">View 360° Profile</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="text-center py-5">
|
||||
<p class="text-muted">No voters found. Try a different search or add a new one.</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
311
core/templates/core/voter_detail.html
Normal file
311
core/templates/core/voter_detail.html
Normal file
@ -0,0 +1,311 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load static %}
|
||||
|
||||
{% block content %}
|
||||
<div class="hero-section" style="padding: 60px 0 100px 0;">
|
||||
<div class="container text-center position-relative">
|
||||
<a href="{% url 'index' %}" class="text-white-50 text-decoration-none mb-3 d-inline-block">← Back to Dashboard</a>
|
||||
<h1 class="display-5 text-white">{{ voter.first_name }} {{ voter.last_name }}</h1>
|
||||
<p class="text-white-50">Voter ID: {{ voter.voter_id }} | {{ voter.district }} / {{ voter.precinct }}</p>
|
||||
<button type="button" class="btn btn-outline-light btn-sm mt-2" data-bs-toggle="modal" data-bs-target="#editVoterModal">
|
||||
<i class="bi bi-pencil-square me-1"></i> Edit Profile
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="voter-profile-header mb-5">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 border-end">
|
||||
<h4 class="mb-4">Demographics & Contact</h4>
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="text-muted small d-block">Full Address</label>
|
||||
<p class="fw-medium">{{ voter.address }}</p>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="text-muted small d-block">Phone / Email</label>
|
||||
<p class="fw-medium">{{ voter.phone|default:"N/A" }}<br>{{ voter.email|default:"N/A" }}</p>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="text-muted small d-block">Registration Date</label>
|
||||
<p class="fw-medium">{{ voter.registration_date|date:"M d, Y"|default:"Unknown" }}</p>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="text-muted small d-block">District / Precinct</label>
|
||||
<p class="fw-medium">{{ voter.district }} / {{ voter.precinct }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4 ps-lg-4">
|
||||
<h4 class="mb-4">Engagement</h4>
|
||||
<div class="mb-4">
|
||||
<label class="text-muted small d-block mb-1">Likelihood to Vote (1-5)</label>
|
||||
<div class="progress" style="height: 10px;">
|
||||
<div class="progress-bar bg-primary" style="width: {% widthratio voter.likelihood_to_vote 5 100 %}%;"></div>
|
||||
</div>
|
||||
<span class="small fw-bold">{{ voter.likelihood_to_vote }}/5</span>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="text-muted small d-block">Candidate Support</label>
|
||||
<span class="badge rounded-pill {% if voter.candidate_support == 'supporting' %}bg-success{% elif voter.candidate_support == 'not_supporting' %}bg-danger{% else %}bg-secondary{% endif %} px-3">
|
||||
{{ voter.get_candidate_support_display }}
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-muted small d-block">Yard Sign</label>
|
||||
<p class="fw-medium"><i class="bi bi-flag"></i> {{ voter.get_yard_sign_status_display }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row g-4 mb-5">
|
||||
<!-- Voting History -->
|
||||
<div class="col-md-6 col-lg-3">
|
||||
<div class="card h-100 p-4 shadow-sm">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h5 class="mb-0"><i class="bi bi-calendar-check text-primary me-2"></i>Voting</h5>
|
||||
<button class="btn btn-link btn-sm p-0" data-bs-toggle="modal" data-bs-target="#addVotingModal"><i class="bi bi-plus-circle-fill fs-5"></i></button>
|
||||
</div>
|
||||
{% for record in voter.voting_records.all %}
|
||||
<div class="d-flex justify-content-between border-bottom pb-2 mb-2">
|
||||
<span class="small">{{ record.description }}</span>
|
||||
<span class="text-muted small">{{ record.election_date|date:"Y" }}</span>
|
||||
</div>
|
||||
{% empty %}
|
||||
<p class="text-muted small">No voting records on file.</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Donations -->
|
||||
<div class="col-md-6 col-lg-3">
|
||||
<div class="card h-100 p-4 shadow-sm">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h5 class="mb-0"><i class="bi bi-cash-coin text-success me-2"></i>Donations</h5>
|
||||
<button class="btn btn-link btn-sm p-0 text-success" data-bs-toggle="modal" data-bs-target="#addDonationModal"><i class="bi bi-plus-circle-fill fs-5"></i></button>
|
||||
</div>
|
||||
{% for donation in voter.donations.all %}
|
||||
<div class="mb-2 border-bottom pb-2">
|
||||
<div class="d-flex justify-content-between">
|
||||
<span class="fw-bold">${{ donation.amount }}</span>
|
||||
<span class="text-muted small">{{ donation.donation_date|date:"M d, Y" }}</span>
|
||||
</div>
|
||||
<div class="extra-small text-muted">{{ donation.method }}</div>
|
||||
</div>
|
||||
{% empty %}
|
||||
<p class="text-muted small">No donation history.</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Event Participation -->
|
||||
<div class="col-md-6 col-lg-3">
|
||||
<div class="card h-100 p-4 shadow-sm">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h5 class="mb-0"><i class="bi bi-people text-info me-2"></i>Events</h5>
|
||||
<button class="btn btn-link btn-sm p-0 text-info" data-bs-toggle="modal" data-bs-target="#addEventModal"><i class="bi bi-plus-circle-fill fs-5"></i></button>
|
||||
</div>
|
||||
{% for participation in voter.event_participations.all %}
|
||||
<div class="mb-3 border-bottom pb-2">
|
||||
<div class="d-flex justify-content-between mb-1">
|
||||
<span class="fw-bold small">{{ participation.event_type }}</span>
|
||||
<span class="text-muted small">{{ participation.event_date|date:"M d, Y" }}</span>
|
||||
</div>
|
||||
{% if participation.description %}
|
||||
<p class="extra-small text-muted mb-0">{{ participation.description|truncatechars:50 }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% empty %}
|
||||
<p class="text-muted small">No events recorded.</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Recent Contacts -->
|
||||
<div class="col-md-6 col-lg-3">
|
||||
<div class="card h-100 p-4 shadow-sm">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h5 class="mb-0"><i class="bi bi-chat-dots text-warning me-2"></i>Contacts</h5>
|
||||
<button class="btn btn-link btn-sm p-0 text-warning" data-bs-toggle="modal" data-bs-target="#addContactModal"><i class="bi bi-plus-circle-fill fs-5"></i></button>
|
||||
</div>
|
||||
{% for contact in voter.contacts.all %}
|
||||
<div class="mb-3 border-bottom pb-2">
|
||||
<div class="d-flex justify-content-between mb-1">
|
||||
<span class="fw-bold small">{{ contact.contact_type }}</span>
|
||||
<span class="text-muted small">{{ contact.contact_date|date:"M d, Y" }}</span>
|
||||
</div>
|
||||
<p class="extra-small text-muted mb-0">{{ contact.description|truncatechars:50 }}</p>
|
||||
</div>
|
||||
{% empty %}
|
||||
<p class="text-muted small">No contact history.</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modals -->
|
||||
|
||||
<!-- Edit Voter Modal -->
|
||||
<div class="modal fade" id="editVoterModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<form action="{% url 'voter_edit' voter.pk %}" method="post">
|
||||
{% csrf_token %}
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Edit Voter Profile</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row g-3">
|
||||
{% for field in voter_form %}
|
||||
<div class="col-md-6">
|
||||
<label class="form-label small">{{ field.label }}</label>
|
||||
{{ field }}
|
||||
{% if field.errors %}
|
||||
<div class="text-danger small">{{ field.errors }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Save Changes</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add Voting Record Modal -->
|
||||
<div class="modal fade" id="addVotingModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form action="{% url 'add_voting_record' voter.pk %}" method="post">
|
||||
{% csrf_token %}
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Add Voting Record</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{% for field in voting_form %}
|
||||
<div class="mb-3">
|
||||
<label class="form-label small">{{ field.label }}</label>
|
||||
{{ field }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Add Record</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add Donation Modal -->
|
||||
<div class="modal fade" id="addDonationModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form action="{% url 'add_donation' voter.pk %}" method="post">
|
||||
{% csrf_token %}
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Log Donation</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{% for field in donation_form %}
|
||||
<div class="mb-3">
|
||||
<label class="form-label small">{{ field.label }}</label>
|
||||
{{ field }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-success">Save Donation</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add Event Modal -->
|
||||
<div class="modal fade" id="addEventModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form action="{% url 'add_event' voter.pk %}" method="post">
|
||||
{% csrf_token %}
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Record Event Participation</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{% for field in event_form %}
|
||||
<div class="mb-3">
|
||||
<label class="form-label small">{{ field.label }}</label>
|
||||
{{ field }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-info text-white">Save Participation</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add Contact Modal -->
|
||||
<div class="modal fade" id="addContactModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form action="{% url 'add_contact' voter.pk %}" method="post">
|
||||
{% csrf_token %}
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Log Voter Contact</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{% for field in contact_form %}
|
||||
<div class="mb-3">
|
||||
<label class="form-label small">{{ field.label }}</label>
|
||||
{{ field }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-warning">Save Contact</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.extra-small {
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
.modal-body input, .modal-body select, .modal-body textarea {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 0.375rem 0.75rem;
|
||||
font-size: 1rem;
|
||||
font-weight: 400;
|
||||
line-height: 1.5;
|
||||
color: #212529;
|
||||
background-color: #fff;
|
||||
background-clip: padding-box;
|
||||
border: 1px solid #ced4da;
|
||||
appearance: none;
|
||||
border-radius: 0.375rem;
|
||||
transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
13
core/urls.py
13
core/urls.py
@ -1,7 +1,12 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import home
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path("", home, name="home"),
|
||||
]
|
||||
path('', views.index, name='index'),
|
||||
path('voter/<int:pk>/', views.voter_detail, name='voter_detail'),
|
||||
path('voter/<int:pk>/edit/', views.voter_edit, name='voter_edit'),
|
||||
path('voter/<int:pk>/add-voting-record/', views.add_voting_record, name='add_voting_record'),
|
||||
path('voter/<int:pk>/add-donation/', views.add_donation, name='add_donation'),
|
||||
path('voter/<int:pk>/add-contact/', views.add_contact, name='add_contact'),
|
||||
path('voter/<int:pk>/add-event/', views.add_event, name='add_event'),
|
||||
]
|
||||
119
core/views.py
119
core/views.py
@ -1,25 +1,98 @@
|
||||
import os
|
||||
import platform
|
||||
from django.shortcuts import render, get_object_or_404, redirect
|
||||
from django.db.models import Q
|
||||
from django.contrib import messages
|
||||
from .models import Voter, VotingRecord, Donation, VoterContact, EventParticipation
|
||||
from .forms import VoterForm, VotingRecordForm, DonationForm, VoterContactForm, EventParticipationForm
|
||||
|
||||
from django import get_version as django_version
|
||||
from django.shortcuts import render
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
def home(request):
|
||||
"""Render the landing screen with loader and environment details."""
|
||||
host_name = request.get_host().lower()
|
||||
agent_brand = "AppWizzy" if host_name == "appwizzy.com" else "Flatlogic"
|
||||
now = timezone.now()
|
||||
|
||||
context = {
|
||||
"project_name": "New Style",
|
||||
"agent_brand": agent_brand,
|
||||
"django_version": django_version(),
|
||||
"python_version": platform.python_version(),
|
||||
"current_time": now,
|
||||
"host_name": host_name,
|
||||
"project_description": os.getenv("PROJECT_DESCRIPTION", ""),
|
||||
"project_image_url": os.getenv("PROJECT_IMAGE_URL", ""),
|
||||
def index(request):
|
||||
query = request.GET.get('q')
|
||||
if query:
|
||||
voters = Voter.objects.filter(
|
||||
Q(first_name__icontains=query) |
|
||||
Q(last_name__icontains=query) |
|
||||
Q(voter_id__icontains=query)
|
||||
)[:10]
|
||||
else:
|
||||
voters = Voter.objects.all().order_by('-created_at')[:5]
|
||||
|
||||
stats = {
|
||||
'total_voters': Voter.objects.count(),
|
||||
'supporters': Voter.objects.filter(candidate_support='supporting').count(),
|
||||
'yard_signs': Voter.objects.filter(yard_sign_status='has').count(),
|
||||
}
|
||||
return render(request, "core/index.html", context)
|
||||
|
||||
return render(request, 'core/index.html', {
|
||||
'voters': voters,
|
||||
'query': query,
|
||||
'stats': stats
|
||||
})
|
||||
|
||||
def voter_detail(request, pk):
|
||||
voter = get_object_or_404(Voter, pk=pk)
|
||||
|
||||
# Forms for adding related records (initialized as empty)
|
||||
context = {
|
||||
'voter': voter,
|
||||
'voter_form': VoterForm(instance=voter),
|
||||
'voting_form': VotingRecordForm(),
|
||||
'donation_form': DonationForm(),
|
||||
'contact_form': VoterContactForm(),
|
||||
'event_form': EventParticipationForm(),
|
||||
}
|
||||
return render(request, 'core/voter_detail.html', context)
|
||||
|
||||
def voter_edit(request, pk):
|
||||
voter = get_object_or_404(Voter, pk=pk)
|
||||
if request.method == 'POST':
|
||||
form = VoterForm(request.POST, instance=voter)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
messages.success(request, 'Voter updated successfully.')
|
||||
return redirect('voter_detail', pk=voter.pk)
|
||||
else:
|
||||
form = VoterForm(instance=voter)
|
||||
return render(request, 'core/voter_detail.html', {'voter': voter, 'voter_form': form})
|
||||
|
||||
def add_voting_record(request, pk):
|
||||
voter = get_object_or_404(Voter, pk=pk)
|
||||
if request.method == 'POST':
|
||||
form = VotingRecordForm(request.POST)
|
||||
if form.is_valid():
|
||||
record = form.save(commit=False)
|
||||
record.voter = voter
|
||||
record.save()
|
||||
messages.success(request, 'Voting record added.')
|
||||
return redirect('voter_detail', pk=voter.pk)
|
||||
|
||||
def add_donation(request, pk):
|
||||
voter = get_object_or_404(Voter, pk=pk)
|
||||
if request.method == 'POST':
|
||||
form = DonationForm(request.POST)
|
||||
if form.is_valid():
|
||||
donation = form.save(commit=False)
|
||||
donation.voter = voter
|
||||
donation.save()
|
||||
messages.success(request, 'Donation added.')
|
||||
return redirect('voter_detail', pk=voter.pk)
|
||||
|
||||
def add_contact(request, pk):
|
||||
voter = get_object_or_404(Voter, pk=pk)
|
||||
if request.method == 'POST':
|
||||
form = VoterContactForm(request.POST)
|
||||
if form.is_valid():
|
||||
contact = form.save(commit=False)
|
||||
contact.voter = voter
|
||||
contact.save()
|
||||
messages.success(request, 'Contact logged.')
|
||||
return redirect('voter_detail', pk=voter.pk)
|
||||
|
||||
def add_event(request, pk):
|
||||
voter = get_object_or_404(Voter, pk=pk)
|
||||
if request.method == 'POST':
|
||||
form = EventParticipationForm(request.POST)
|
||||
if form.is_valid():
|
||||
participation = form.save(commit=False)
|
||||
participation.voter = voter
|
||||
participation.save()
|
||||
messages.success(request, 'Event participation added.')
|
||||
return redirect('voter_detail', pk=voter.pk)
|
||||
|
||||
48
populate_engagement.py
Normal file
48
populate_engagement.py
Normal file
@ -0,0 +1,48 @@
|
||||
import os
|
||||
import django
|
||||
import random
|
||||
from datetime import date, timedelta
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||
django.setup()
|
||||
|
||||
from core.models import Voter, Donation, EventParticipation
|
||||
|
||||
def populate_engagement_data():
|
||||
voters = Voter.objects.all()
|
||||
|
||||
event_types = ['Town Hall', 'Neighborhood Walk', 'Phone Bank', 'Fundraiser Dinner', 'Rally']
|
||||
event_descriptions = [
|
||||
'Discussed local infrastructure issues.',
|
||||
'Canvassed the precinct with volunteers.',
|
||||
'Made 50 calls to likely voters.',
|
||||
'Annual gala for the candidate.',
|
||||
'Major campaign kickoff event.'
|
||||
]
|
||||
|
||||
for voter in voters:
|
||||
# 30% chance of having donations
|
||||
if random.random() < 0.3:
|
||||
num_donations = random.randint(1, 4)
|
||||
for _ in range(num_donations):
|
||||
Donation.objects.create(
|
||||
voter=voter,
|
||||
donation_date=date.today() - timedelta(days=random.randint(1, 365)),
|
||||
amount=random.choice([10, 25, 50, 100, 250, 500])
|
||||
)
|
||||
|
||||
# 40% chance of having events
|
||||
if random.random() < 0.4:
|
||||
num_events = random.randint(1, 3)
|
||||
for _ in range(num_events):
|
||||
EventParticipation.objects.create(
|
||||
voter=voter,
|
||||
event_date=date.today() - timedelta(days=random.randint(1, 180)),
|
||||
event_type=random.choice(event_types),
|
||||
description=random.choice(event_descriptions)
|
||||
)
|
||||
|
||||
print(f"Populated donations and events for {voters.count()} voters.")
|
||||
|
||||
if __name__ == '__main__':
|
||||
populate_engagement_data()
|
||||
@ -1,4 +1,75 @@
|
||||
/* Custom styles for the application */
|
||||
body {
|
||||
font-family: system-ui, -apple-system, sans-serif;
|
||||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Outfit:wght@600;700&display=swap');
|
||||
|
||||
:root {
|
||||
--primary-navy: #0F172A;
|
||||
--electric-blue: #3B82F6;
|
||||
--emerald-accent: #10B981;
|
||||
--soft-bg: #F8FAFC;
|
||||
--card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Inter', sans-serif;
|
||||
background-color: var(--soft-bg);
|
||||
color: var(--primary-navy);
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, .navbar-brand {
|
||||
font-family: 'Outfit', sans-serif;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.hero-section {
|
||||
background: linear-gradient(135deg, var(--primary-navy) 0%, #1E293B 100%);
|
||||
color: white;
|
||||
padding: 80px 0;
|
||||
border-bottom: 4px solid var(--electric-blue);
|
||||
}
|
||||
|
||||
.search-glass {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
backdrop-filter: blur(10px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: none;
|
||||
border-radius: 16px;
|
||||
box-shadow: var(--card-shadow);
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
transform: translateY(-4px);
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: var(--electric-blue);
|
||||
border: none;
|
||||
padding: 10px 24px;
|
||||
border-radius: 8px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.badge-support {
|
||||
background-color: var(--emerald-accent);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
border-left: 4px solid var(--electric-blue);
|
||||
}
|
||||
|
||||
.voter-profile-header {
|
||||
background-color: white;
|
||||
padding: 40px;
|
||||
border-radius: 20px;
|
||||
margin-top: -40px;
|
||||
box-shadow: var(--card-shadow);
|
||||
}
|
||||
@ -1,21 +1,75 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Outfit:wght@600;700&display=swap');
|
||||
|
||||
:root {
|
||||
--bg-color-start: #6a11cb;
|
||||
--bg-color-end: #2575fc;
|
||||
--text-color: #ffffff;
|
||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||
--primary-navy: #0F172A;
|
||||
--electric-blue: #3B82F6;
|
||||
--emerald-accent: #10B981;
|
||||
--soft-bg: #F8FAFC;
|
||||
--card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
background-color: var(--soft-bg);
|
||||
color: var(--primary-navy);
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, .navbar-brand {
|
||||
font-family: 'Outfit', sans-serif;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.hero-section {
|
||||
background: linear-gradient(135deg, var(--primary-navy) 0%, #1E293B 100%);
|
||||
color: white;
|
||||
padding: 80px 0;
|
||||
border-bottom: 4px solid var(--electric-blue);
|
||||
}
|
||||
|
||||
.search-glass {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
backdrop-filter: blur(10px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: none;
|
||||
border-radius: 16px;
|
||||
box-shadow: var(--card-shadow);
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
transform: translateY(-4px);
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: var(--electric-blue);
|
||||
border: none;
|
||||
padding: 10px 24px;
|
||||
border-radius: 8px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.badge-support {
|
||||
background-color: var(--emerald-accent);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
border-left: 4px solid var(--electric-blue);
|
||||
}
|
||||
|
||||
.voter-profile-header {
|
||||
background-color: white;
|
||||
padding: 40px;
|
||||
border-radius: 20px;
|
||||
margin-top: -40px;
|
||||
box-shadow: var(--card-shadow);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user