diff options
Diffstat (limited to '')
-rw-r--r-- | ctrack/register/forms.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/ctrack/register/forms.py b/ctrack/register/forms.py index d3e93ab..2afc1a1 100644 --- a/ctrack/register/forms.py +++ b/ctrack/register/forms.py @@ -16,13 +16,15 @@ from ctrack.register.models import ( ) -class AddMeetingForm(forms.ModelForm): +class CreateSimpleDateTimeEventForm(forms.ModelForm): class Meta: model = SingleDateTimeEvent fields = [ "type_descriptor", "short_description", "datetime", + "requested_response_date", + "response_received_date", "comments", "location", ] @@ -31,6 +33,17 @@ class AddMeetingForm(forms.ModelForm): self.user = kwargs.pop("user") super().__init__(*args, **kwargs) + def clean(self): + cleaned_data = super().clean() + date = cleaned_data.get("datetime") + if not date: + return cleaned_data + # WOOO - walrus operator + if requested := cleaned_data.get("requested_response_date"): + if requested < date.date(): + raise ValidationError("Requested response cannot be before date.") + return cleaned_data + def save(self, **kwargs): form = super().save(commit=False) form.user = self.user @@ -68,8 +81,8 @@ class CAFTwinDateEventForm(forms.ModelForm): caf = self.cleaned_data["related_caf"] existing_obj = ( CAFTwinDateEvent.objects.filter(start_date=data) - .filter(related_caf=caf) - .first() + .filter(related_caf=caf) + .first() ) if existing_obj: raise ValidationError( |