Skip to content

Commit 22b0185

Browse files
committed
Clean imports and force address to be required as shown in ui
1 parent 5d2d958 commit 22b0185

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

appointment/forms.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
from django import forms
1010
from django.utils.translation import gettext as _
11-
from phonenumber_field.formfields import PhoneNumberField, SplitPhoneNumberField
12-
from phonenumber_field.widgets import PhoneNumberPrefixWidget
11+
from phonenumber_field.formfields import SplitPhoneNumberField
1312

1413
from .models import (
1514
Appointment, AppointmentRequest, AppointmentRescheduleHistory, DayOff, Service, StaffMember,
@@ -21,7 +20,8 @@
2120

2221
class SlotForm(forms.Form):
2322
selected_date = forms.DateField(validators=[not_in_the_past])
24-
staff_member = forms.ModelChoiceField(StaffMember.objects.all(), error_messages={'invalid_choice': 'Staff member does not exist'})
23+
staff_member = forms.ModelChoiceField(StaffMember.objects.all(),
24+
error_messages={'invalid_choice': 'Staff member does not exist'})
2525

2626

2727
class AppointmentRequestForm(forms.ModelForm):
@@ -49,25 +49,26 @@ class Meta:
4949
def __init__(self, *args, **kwargs):
5050
super().__init__(*args, **kwargs)
5151
self.fields['phone'].widget.attrs.update(
52-
{
53-
'placeholder': '1234567890'
54-
})
52+
{
53+
'placeholder': '1234567890'
54+
})
5555
self.fields['additional_info'].widget.attrs.update(
56-
{
57-
'rows': 2,
58-
'class': 'form-control',
59-
})
56+
{
57+
'rows': 2,
58+
'class': 'form-control',
59+
})
6060
self.fields['address'].widget.attrs.update(
61-
{
62-
'rows': 2,
63-
'class': 'form-control',
64-
'placeholder': '1234 Main St, City, State, Zip Code'
65-
})
61+
{
62+
'rows': 2,
63+
'class': 'form-control',
64+
'placeholder': '1234 Main St, City, State, Zip Code',
65+
'required': 'true'
66+
})
6667
self.fields['additional_info'].widget.attrs.update(
67-
{
68-
'class': 'form-control',
69-
'placeholder': 'I would like to be contacted by phone.'
70-
})
68+
{
69+
'class': 'form-control',
70+
'placeholder': 'I would like to be contacted by phone.'
71+
})
7172

7273

7374
class ClientDataForm(forms.Form):
@@ -162,9 +163,9 @@ def __init__(self, *args, **kwargs):
162163
existing_staff_user_ids = StaffMember.objects.values_list('user', flat=True)
163164
# Filter queryset for user field to include only superusers or users not already staff members
164165
self.fields['user'].queryset = get_user_model().objects.filter(
165-
is_superuser=True
166+
is_superuser=True
166167
).exclude(id__in=existing_staff_user_ids) | get_user_model().objects.exclude(
167-
id__in=existing_staff_user_ids
168+
id__in=existing_staff_user_ids
168169
)
169170

170171

0 commit comments

Comments
 (0)