diff --git a/core/__pycache__/admin.cpython-311.pyc b/core/__pycache__/admin.cpython-311.pyc index 8335e4f..9619ec4 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 fdd70b9..48580fa 100644 Binary files a/core/__pycache__/forms.cpython-311.pyc and b/core/__pycache__/forms.cpython-311.pyc differ diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index 1475653..be74b0a 100644 Binary files a/core/__pycache__/urls.cpython-311.pyc and b/core/__pycache__/urls.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index 0f3b89b..8695930 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 7ce2f67..1350ddf 100644 --- a/core/admin.py +++ b/core/admin.py @@ -181,7 +181,7 @@ class ParticipationStatusAdmin(admin.ModelAdmin): class InterestAdmin(admin.ModelAdmin): list_display = ('name', 'tenant') list_filter = ('tenant',) - fields = ('tenant', 'donation_goal', 'twilio_account_sid', 'twilio_auth_token', 'twilio_from_number') + fields = ('tenant', 'name') search_fields = ('name',) class VotingRecordInline(admin.TabularInline): @@ -724,7 +724,7 @@ class EventAdmin(BaseImportAdminMixin, admin.ModelAdmin): class VolunteerAdmin(BaseImportAdminMixin, admin.ModelAdmin): list_display = ('first_name', 'last_name', 'email', 'phone', 'tenant', 'user') list_filter = ('tenant',) - fields = ('tenant', 'donation_goal', 'twilio_account_sid', 'twilio_auth_token', 'twilio_from_number') + fields = ('tenant', 'user', 'first_name', 'last_name', 'email', 'phone', 'interests') search_fields = ('first_name', 'last_name', 'email', 'phone') inlines = [VolunteerEventInline, InteractionInline] filter_horizontal = ('interests',) @@ -1779,4 +1779,4 @@ class VoterLikelihoodAdmin(BaseImportAdminMixin, admin.ModelAdmin): class CampaignSettingsAdmin(admin.ModelAdmin): list_display = ('tenant', 'donation_goal', 'twilio_from_number') list_filter = ('tenant',) - fields = ('tenant', 'donation_goal', 'twilio_account_sid', 'twilio_auth_token', 'twilio_from_number') + fields = ('tenant', 'donation_goal', 'twilio_account_sid', 'twilio_auth_token', 'twilio_from_number') \ No newline at end of file diff --git a/core/forms.py b/core/forms.py index 90b9b8c..74dc8ed 100644 --- a/core/forms.py +++ b/core/forms.py @@ -1,5 +1,5 @@ from django import forms -from .models import Voter, Interaction, Donation, VoterLikelihood, InteractionType, DonationMethod, ElectionType, Event, EventParticipation, EventType, Tenant, ParticipationStatus +from .models import Voter, Interaction, Donation, VoterLikelihood, InteractionType, DonationMethod, ElectionType, Event, EventParticipation, EventType, Tenant, ParticipationStatus, Volunteer, VolunteerEvent class VoterForm(forms.ModelForm): class Meta: @@ -146,6 +146,25 @@ class EventParticipationForm(forms.ModelForm): self.fields['event'].widget.attrs.update({'class': 'form-select'}) self.fields['participation_status'].widget.attrs.update({'class': 'form-select'}) +class EventParticipantAddForm(forms.ModelForm): + class Meta: + model = EventParticipation + fields = ['voter', 'participation_status'] + + def __init__(self, *args, tenant=None, **kwargs): + super().__init__(*args, **kwargs) + if tenant: + voter_id = self.data.get('voter') or self.initial.get('voter') + if voter_id: + self.fields['voter'].queryset = Voter.objects.filter(tenant=tenant, id=voter_id) + else: + self.fields['voter'].queryset = Voter.objects.none() + self.fields['participation_status'].queryset = ParticipationStatus.objects.filter(tenant=tenant, is_active=True) + for field in self.fields.values(): + field.widget.attrs.update({'class': 'form-control'}) + self.fields['voter'].widget.attrs.update({'class': 'form-select'}) + self.fields['participation_status'].widget.attrs.update({'class': 'form-select'}) + class EventForm(forms.ModelForm): class Meta: model = Event @@ -227,3 +246,33 @@ class VolunteerImportForm(forms.Form): super().__init__(*args, **kwargs) self.fields['tenant'].widget.attrs.update({'class': 'form-control form-select'}) self.fields['file'].widget.attrs.update({'class': 'form-control'}) + +class VolunteerForm(forms.ModelForm): + class Meta: + model = Volunteer + fields = ['first_name', 'last_name', 'email', 'phone', 'interests'] + + def __init__(self, *args, tenant=None, **kwargs): + super().__init__(*args, **kwargs) + if tenant: + from .models import Interest + self.fields['interests'].queryset = Interest.objects.filter(tenant=tenant) + for field in self.fields.values(): + field.widget.attrs.update({'class': 'form-control'}) + + # self.fields['interests'].widget = forms.SelectMultiple() + # Re-apply class for checkbox + self.fields['interests'].widget.attrs.update({'class': 'form-select tom-select'}) + +class VolunteerEventForm(forms.ModelForm): + class Meta: + model = VolunteerEvent + fields = ['event', 'role'] + + def __init__(self, *args, tenant=None, **kwargs): + super().__init__(*args, **kwargs) + if tenant: + self.fields['event'].queryset = Event.objects.filter(tenant=tenant) + for field in self.fields.values(): + field.widget.attrs.update({'class': 'form-control'}) + self.fields['event'].widget.attrs.update({'class': 'form-select'}) diff --git a/core/templates/base.html b/core/templates/base.html index d42c9a2..b90e601 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -40,6 +40,12 @@