diff --git a/ERD.md b/ERD.md index b1bb0cf..92f991e 100644 --- a/ERD.md +++ b/ERD.md @@ -7,7 +7,6 @@ erDiagram Tenant ||--o{ DonationMethod : defines Tenant ||--o{ ElectionType : defines Tenant ||--o{ EventType : defines - Tenant ||--o{ ParticipationType : defines Tenant ||--o{ Voter : belongs_to Tenant ||--o{ Event : organizes @@ -25,7 +24,6 @@ erDiagram InteractionType ||--o{ Interaction : categorizes DonationMethod ||--o{ Donation : categorizes ElectionType ||--o{ VoterLikelihood : categorizes - ParticipationType ||--o{ EventParticipation : categorizes Tenant { int id PK @@ -78,13 +76,6 @@ erDiagram boolean is_active } - ParticipationType { - int id PK - int tenant_id FK - string name - boolean is_active - } - Voter { int id PK int tenant_id FK @@ -105,6 +96,7 @@ erDiagram VotingRecord { int id PK int voter_id FK + string participation_type date election_date string election_description string primary_party @@ -122,12 +114,13 @@ erDiagram int id PK int event_id FK int voter_id FK - int participation_type_id FK + string participation_type } Donation { int id PK int voter_id FK + string participation_type date date int method_id FK decimal amount @@ -136,6 +129,7 @@ erDiagram Interaction { int id PK int voter_id FK + string participation_type int type_id FK date date string description @@ -145,6 +139,7 @@ erDiagram VoterLikelihood { int id PK int voter_id FK + string participation_type int election_type_id FK string likelihood } diff --git a/core/__pycache__/admin.cpython-311.pyc b/core/__pycache__/admin.cpython-311.pyc index b6b7208..66bd230 100644 Binary files a/core/__pycache__/admin.cpython-311.pyc and b/core/__pycache__/admin.cpython-311.pyc differ diff --git a/core/__pycache__/forms.cpython-311.pyc b/core/__pycache__/forms.cpython-311.pyc index 1bb7bb9..3b4f52c 100644 Binary files a/core/__pycache__/forms.cpython-311.pyc and b/core/__pycache__/forms.cpython-311.pyc differ diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index 887c76e..223fb5d 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index da2d528..fd154aa 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/admin.py b/core/admin.py index 1f6d628..c79005e 100644 --- a/core/admin.py +++ b/core/admin.py @@ -1,8 +1,7 @@ from django.contrib import admin from .models import ( - Tenant, TenantUserRole, InteractionType, DonationMethod, ElectionType, EventType, - ParticipationType, Voter, VotingRecord, Event, EventParticipation, Donation, - Interaction, VoterLikelihood + Tenant, TenantUserRole, InteractionType, DonationMethod, ElectionType, EventType, Voter, + VotingRecord, Event, EventParticipation, Donation, Interaction, VoterLikelihood ) class TenantUserRoleInline(admin.TabularInline): @@ -45,12 +44,6 @@ class EventTypeAdmin(admin.ModelAdmin): list_filter = ('tenant', 'is_active') search_fields = ('name',) -@admin.register(ParticipationType) -class ParticipationTypeAdmin(admin.ModelAdmin): - list_display = ('name', 'tenant', 'is_active') - list_filter = ('tenant', 'is_active') - search_fields = ('name',) - class VotingRecordInline(admin.TabularInline): model = VotingRecord extra = 1 @@ -82,4 +75,4 @@ class EventAdmin(admin.ModelAdmin): @admin.register(EventParticipation) class EventParticipationAdmin(admin.ModelAdmin): list_display = ('voter', 'event', 'participation_type') - list_filter = ('event__tenant', 'event', 'participation_type') \ No newline at end of file + list_filter = ('event__tenant', 'event', 'participation_type') diff --git a/core/forms.py b/core/forms.py index 72519d6..2ec45de 100644 --- a/core/forms.py +++ b/core/forms.py @@ -71,7 +71,7 @@ class VoterLikelihoodForm(forms.ModelForm): class EventParticipationForm(forms.ModelForm): class Meta: model = EventParticipation - fields = ['event'] + fields = ['event', 'participation_type'] def __init__(self, *args, tenant=None, **kwargs): super().__init__(*args, **kwargs) @@ -80,6 +80,7 @@ class EventParticipationForm(forms.ModelForm): for field in self.fields.values(): field.widget.attrs.update({'class': 'form-control'}) self.fields['event'].widget.attrs.update({'class': 'form-select'}) + self.fields['participation_type'].widget.attrs.update({'class': 'form-select'}) class EventForm(forms.ModelForm): class Meta: @@ -108,4 +109,4 @@ class EventTypeForm(forms.ModelForm): for field in self.fields.values(): if not isinstance(field.widget, forms.CheckboxInput): field.widget.attrs.update({'class': 'form-control'}) - self.fields['is_active'].widget.attrs.update({'class': 'form-check-input'}) \ No newline at end of file + self.fields['is_active'].widget.attrs.update({'class': 'form-check-input'}) diff --git a/core/migrations/0005_eventparticipation_participation_type.py b/core/migrations/0005_eventparticipation_participation_type.py new file mode 100644 index 0000000..e49ff24 --- /dev/null +++ b/core/migrations/0005_eventparticipation_participation_type.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.7 on 2026-01-24 16:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0004_remove_voter_geocode_donationmethod_is_active_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='eventparticipation', + name='participation_type', + field=models.CharField(choices=[('invited', 'Invited'), ('invited_not_attended', "Invited but didn't attend"), ('attended', 'Attended')], default='invited', max_length=50), + ), + ] diff --git a/core/migrations/0005_participationtype_and_more.py b/core/migrations/0005_participationtype_and_more.py deleted file mode 100644 index d89b0b9..0000000 --- a/core/migrations/0005_participationtype_and_more.py +++ /dev/null @@ -1,31 +0,0 @@ -# Generated by Django 5.2.7 on 2026-01-24 15:43 - -import django.db.models.deletion -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('core', '0004_remove_voter_geocode_donationmethod_is_active_and_more'), - ] - - operations = [ - migrations.CreateModel( - name='ParticipationType', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=100)), - ('is_active', models.BooleanField(default=True)), - ('tenant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='participation_types', to='core.tenant')), - ], - options={ - 'unique_together': {('tenant', 'name')}, - }, - ), - migrations.AddField( - model_name='eventparticipation', - name='participation_type', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.participationtype'), - ), - ] diff --git a/core/migrations/__pycache__/0005_eventparticipation_participation_type.cpython-311.pyc b/core/migrations/__pycache__/0005_eventparticipation_participation_type.cpython-311.pyc new file mode 100644 index 0000000..594b2c5 Binary files /dev/null and b/core/migrations/__pycache__/0005_eventparticipation_participation_type.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index cd5acd0..be81b57 100644 --- a/core/models.py +++ b/core/models.py @@ -41,7 +41,7 @@ class InteractionType(models.Model): unique_together = ('tenant', 'name') def __str__(self): - return self.name + return f"{self.name} ({self.tenant.name})" class DonationMethod(models.Model): tenant = models.ForeignKey(Tenant, on_delete=models.CASCADE, related_name='donation_methods') @@ -52,7 +52,7 @@ class DonationMethod(models.Model): unique_together = ('tenant', 'name') def __str__(self): - return self.name + return f"{self.name} ({self.tenant.name})" class ElectionType(models.Model): tenant = models.ForeignKey(Tenant, on_delete=models.CASCADE, related_name='election_types') @@ -63,7 +63,7 @@ class ElectionType(models.Model): unique_together = ('tenant', 'name') def __str__(self): - return self.name + return f"{self.name} ({self.tenant.name})" class EventType(models.Model): tenant = models.ForeignKey(Tenant, on_delete=models.CASCADE, related_name='event_types') @@ -74,18 +74,7 @@ class EventType(models.Model): unique_together = ('tenant', 'name') def __str__(self): - return self.name - -class ParticipationType(models.Model): - tenant = models.ForeignKey(Tenant, on_delete=models.CASCADE, related_name='participation_types') - name = models.CharField(max_length=100) - is_active = models.BooleanField(default=True) - - class Meta: - unique_together = ('tenant', 'name') - - def __str__(self): - return self.name + return f"{self.name} ({self.tenant.name})" class Voter(models.Model): SUPPORT_CHOICES = [ @@ -136,12 +125,18 @@ class Event(models.Model): return f"{self.event_type} on {self.date}" class EventParticipation(models.Model): + PARTICIPATION_TYPE_CHOICES = [ + ("invited", "Invited"), + ("invited_not_attended", "Invited but didn't attend"), + ("attended", "Attended"), + ] + event = models.ForeignKey(Event, on_delete=models.CASCADE, related_name='participations') voter = models.ForeignKey(Voter, on_delete=models.CASCADE, related_name='event_participations') - participation_type = models.ForeignKey(ParticipationType, on_delete=models.SET_NULL, null=True, blank=True) + participation_type = models.CharField(max_length=50, choices=PARTICIPATION_TYPE_CHOICES, default='invited') def __str__(self): - return f"{self.voter} at {self.event}" + return f"{self.voter} at {self.event} ({self.get_participation_type_display()})" class Donation(models.Model): voter = models.ForeignKey(Voter, on_delete=models.CASCADE, related_name='donations') @@ -176,4 +171,4 @@ class VoterLikelihood(models.Model): unique_together = ('voter', 'election_type') def __str__(self): - return f"{self.voter} - {self.election_type}: {self.get_likelihood_display()}" \ No newline at end of file + return f"{self.voter} - {self.election_type}: {self.get_likelihood_display()}" diff --git a/core/templates/core/voter_detail.html b/core/templates/core/voter_detail.html index 6b3b9bc..6432bb7 100644 --- a/core/templates/core/voter_detail.html +++ b/core/templates/core/voter_detail.html @@ -283,6 +283,7 @@